Hi all
I’m useing debian 7.11(kernel 3.8) version image.
I’m trying to use rs485 cape on BBB or BBG. Below are the cape I use.
485 CAN CAPE
http://www.waveshare.com/wiki/RS485_CAN_CAPE
485 CLICK BOARD
http://www.mikroe.com/click/rs485-3.3v/
As I know these boards don’t have capability to auto handle read/write mode switching.
I try to use linux rs485 mode to auto handle switching problem.
The attached file is my sample code.
My problem is if I read data after writing, the receiving data will add a redundant data(0x00) at the beginning of the buffer.
Below is the result.
This is modbus command, that due to the redundant data, the modbus command will be failed.
So I use raw command to get data.
send: 01 04 00 00 00 01 31 CA
receive: 00 01 04 02 01 3E 39 70
send: 01 04 00 01 00 01 60 0A
receive: 00 01 04 02 00 E2 39 79
send: 02 04 00 00 00 01 31 F9
receive: 00 02 04 02 00 BA 7C 83
send: 02 04 00 01 00 01 60 39
receive: 00 02 04 02 00 FA 7D 73
send: 03 04 00 00 00 01 30 28
receive: 00 03 04 02 03 11 00 0C
send: 03 04 00 01 00 01 61 E8
receive: 00 03 04 02 00 DE 40 A8
This redundant data is not read data from modbus device. I use another rs485 cable to monitor the data will not have this redundant data.
Like this:
send: 01 04 00 00 00 01 31 CA
receive: 01 04 02 01 3E 39 70
If I only use receive mode, there will not be any redundant data in the buffer.
As I tried, kernel 4.4 cannot work 485 system call.
I’m not familiar in kernel, does anyone could give me some advice?
Many thanks,
Harvey
click_mod_sensor.py (4.35 KB)