Serial binding encoding problems

Could anyone help me?
I started exploring OpenHab with the windows version. As a result, I managed to achieve the work with a pulse counter connected via RS485-USB (virtual COM port). I managed to send requests to him and receive it, as well as process the answers. But not everything was good in the beginning. And in the beginning I could only send requests. The counter did not answer.
The problem was solved by adding the Windows environment variable:
JAVA_TOOL_OPTIONS = -Dfile.encoding = ISO-8859-1
I debugged the code and decided to move it to RPi2 (Openhabian).
I found the port I needed:
Dmesg | Grep tty
it is cdc_acm 1-1.2: 1.0: ttyACM0: USB ACM device
But whatever I do, I never got a response from the counter. In the logs only send the request.
And I tried this:

  2. sudo /usr/sbin/locale-gen en_US.ISO-8859-1
    sudo /usr/sbin/update-locale LANG=en_US.ISO-8859-1
  3. /etc/default/openhab2:

What did I miss? Help me please…

The adventure continues. I changed the port name to /dev/ttyAMA0@9600.
And I connected the console to it.
I send 1, 2, 3, 4, 5, 6, 7, 8, 9, A (HEX)
I get 1, 2, 3, 4, 5, 6, 7, 8, 9, A (HEX)

It seems all right, but no:
I send 0, 6, 26, 17, 4, A, 7, F, 36, 8 (HEX)
I get 7, F, 36, 8, 0, 6, 26,17, 4, A (HEX)
There was a change in the order of bytes! What’s the matter?

Problem solved!

1 Like