Serial Module Possible Error

The first time my serial write code is launched I get the following message in the output console.

Serialio Library: version 10.1.2: build 9221
Copyright © 1996-2012, All Rights Reserved.“Windows XP” os.arch=“x86”
java.lang.UnsatisfiedLinkError: no jspWin in java.library.path: Check that native library jspWin is in proper directory

What does this message mean? I’m currently unable to get my write code to work and I’m wondering if it’s due to this message.

No, that message shouldn’t be a problem (even though it seems like it would be).

Post your script and an explanation and we can take a look at what’s going on.

Below is the code I’m using. The code is inside a button mouse click event. I also have another button that configures the serial port settings. The serial device I’m using connects to the computer through a USB port but it shows up in my device manager as a serial port.

The USB device came with a small program that will let me type the “BB 03 00 47” hex code and write it, then it reads the response from the network. I have use this program and I get the correct response back.

Also the USB device has a small red LED on it that turns when a message is sent to it. The light never comes on when I push the button in Ignition, but it does when using the program that came with the device.

port = "COM8"


system.serial.write(port,"BB 03 00 47")

PortRead = system.serial.readBytesAsString(port, 14, 1000)
"data read" == PortRead


My first guess would be that the code you’ve got is sending the string “BB 03 00 47” to the device - not the hex bytes you probably want to send.

You could try two different things:

  1. Keep using system.serial.write() and pass in the string “\xBB\x03\x00\x47”. (Not sure if this will work)
  2. Use system.serial.writeBytes(), which expects a java.lang.byte[].

I will try the code above. The manual that came with UBS device indicates the red led will turn every time the device sees a message. Is there any chance that my code is not opening com8 port. Also I tried to use the read line function and it did not detect any data when data was available at the port.

It’s more likely that the serial port isn’t configured correctly. There’s an Exception thrown from openSerialPort() when it can’t be opened.

When I try using the system.serial.writeBytes the system throws an error that the value for “BB” 187 is out of range. How do I change the write bytes to expect unsigned values?

Hmm… how exactly are you calling writeBytes?

The call is being done with a button (Mouse Click Event). I did an independent test using the Hercules terminal program, it’s like hyperterminal only easier to use. I was able to write and read the serial data. This terminal software is not related to the device I’m using so it should not be manipulating the message (meaning it’s not adding any additional data to the message).

In that case it should be sufficient to stick with system.serial.write() and keep using strings.

What version of Ignition/Serial module do you have?

Do you happen to have access to a serial “sniffer” device (or whatever they’re called. They sit in between the two points and intercept traffic)?

I got the write command to work. Below is the code I’m using to write a two byte HEX message (82 7D) out of the serial port:


port = "COM8"

system.serial.writeBytes(port, "\x82\x7D")

Now the next step is to read data. The write message above doesn’t request the device to provide a response, but I do have other write commands that do. So is there away to cast the system.serial.readBytes data to HEX? Also is there any way to create a port listener? If so will the port listener need to be disabled when a write command is activated?