[RESOLVED] FX30 Serial with Java

Hello,
We have develop and tested a Java program which communicates with a Modbus device via a serial port.

We tested it successfully on our machine.

Then, we tried on our FX30 serial. We do have HSL0 and HSL1 ports and we configured the UART 1 in mode 17 (linux application) with mapuart command but the program did not work: nothing happens and no data were retrieved by FX30 from the Modbus device.

I guess it might be due to some configuration I am missing, or a Java library not compatible with the FX30, or a FX30 software issue.

In our Java application, for the Modbus library we use j2mod 2.3.4 which support jSerialComm.

Our FX30 serial firmware info:
Firmware Version: SWI9X15Y_07.11.22.00 r33729 CARMD-EV-FRMWR1 2017/01/11 18:04:06
Bootloader Version: SWI9X15Y_07.11.22.00 r33729 CARMD-EV-FRMWR1 2017/01/11 18:04:06
Linux Version: 3.14.29ltsi-a00e464379_c5f87a778d #2 PREEMPT Wed Apr 19 15:36:04 PDT 2017
FX30 Version: R13.1.3.001

Could anyone help us on this? I think I am missing some configuration somewhere but I could not find where.

Thank you :slight_smile:

Hi eszymko,

The FX30 does not have a serial port application. You’ll still need to create you own app to process the serial data.

Regards,
Chris

Hi cchenry,
Yes, this is what I’ve done: I created a java application that read from the Serial port of the FX30. The java application use the jSerialComm library to communicate with the port.

Hi eszymko,

I’m not certain if a Java app will run on the FX30, were you able to add the required libraries?

Can you double check the basics to ensure cfg matches, like baud rate, data bits, etc. Is your app talking to /dev/ttyHSL0?

Can you test one side at a time, using echo and cat?

Hi,
Yes, we have recompiled the Java sources in order to make them work on the FX30 :wink:

On one side we have the modbus device that we configured and on the other side we have our Java application trying to read the register.
The Java application has a configuration file in which we specified the configuration of the serial (the port, here ttyHSL0, the baudrate, the stop bit, the encoding, …).
We tested this conf file from our dev machine and it worked correctly. Then when using the exact same conf file but on the FX30, it does not work.

How can I test echo and cat? Maybe something like

echo -ne "test"  > /dev/ttyHSL0

? I tried with microcom already but I did not get any response from the modbus and I did not see the modbus receiving any data either.

Yes, you should be able to echo to /dev/ttyHSL0 and view the “test” on your terminal application on the host.

You can also send serial data on your host and view it on the FX30:
cat /dev/ttyHSL0

Can you check the HSL0 baud rate?
stty -F /dev/ttyHSL0 -a

What’s the MAPUART value?
AT!MAPUART?

Hi,
The HSL0 baud rate:

root@fx30s:~# stty -F /dev/ttyHSL0 -a
speed 9600 baud;stty: /dev/ttyHSL0
 line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O;
min = 0; time = 50;
-parenb -parodd cs8 -hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

The result of the AT!MAPUART:

root@fx30s:~# microcom -E /dev/ttyAT
at!mapuart?
!MAPUART: 17,17

OK
root@fx30s:~#

When i do the echo, I see nothing on the modbus device.
When I do the cat, nothing happen

Hello,
Just to keep you updated: it works now!

After having test all the steps of the communication, it appears it was due to the wires: Rx and Tx wires were switched.

It must came from the USB to Serial adaptor which must have its Rx and Tx switched somehow.

Anyway, thank you very much for the kind support :slight_smile:

Gabriel.