Forum

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

   

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
How to use RS485 under linux in One?
2018 年 02 月 16 日
21:33:00
pongraczi
Hungary
Moderator
Forum Posts: 20
Member Since:
2015 年 02 月 11 日
Offline

Hi,

Background:
I use linux on One and I can see 3 serial ports.
I think, they are ok, but I am interesting about using the RS485, which is, as I remember on the port4, which is non-exists, at least the linux kernel cannot see.
So, as the RS485 is a half duplex, I can see a TXDEN4 pin besides of TX4/RX4 pins connected to the SOM module to be able to decide between send/receive a message over the RS485 chip (SN65HVD485EDR).

So, I guess, when using 86Duino or the 86Duino SDK on top of linux, the library somehow solves the missing Serial port4 problem.

My questions:
1. Is that normal to see only 3 serial ports on linux, even on One, where the 4th serial port definitely exists?
2. Is that possible to access to the RS485 on linux, without using the SDK?

Thank you!

2018 年 02 月 16 日
22:37:09
pongraczi
Hungary
Moderator
Forum Posts: 20
Member Since:
2015 年 02 月 11 日
Offline

I checked the RS485, using 86Duino IDE, it is working as expected. It is not on linux, but the arduino code.
Only thing, one should use the Serial485 instead of Serial etc., otherwise it is working like a charm.

So, theoretically it seems, it is possible to use it on linux, if we use the 86Duino SDK, right?

2018 年 02 月 19 日
18:00:23
pongraczi
Hungary
Moderator
Forum Posts: 20
Member Since:
2015 年 02 月 11 日
Offline

Unfortunately the test program cannot set the COM4 (ttyS3) for RS485.

I got this error message when I run the test code:
fail to get termios settingsCOM init fail!!

Do I need to setup something special for linux kernel to get the 4th serial port working? Serial ports (COM1, COM2, COM3) are working, COM4 does not.

Reference:
- rs485 test code from arduino: https://www.arduino.cc/en/Tutorial/SerialCallResponseASCII
some modification to not use any sensors, only ASCII texts sent through the rs485. On 86duino, it is working as expected.
- kernel is 3.18.29, standard serial support, 4 ports by default
[ 0.678330] serial8250: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[ 0.683316] serial8250: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A
[ 0.688197] serial8250: ttyS2 at I/O 0x3e8 (irq = 4, base_baud = 115200) is a 16550A

Thanks.

2018 年 02 月 19 日
20:24:37
pongraczi
Hungary
Moderator
Forum Posts: 20
Member Since:
2015 年 02 月 11 日
Offline

I tested the rs485 test program on L86Duntu where it worked as expected.
So, technically the hardware is ok and can work but I think I missed something to get it work.
What I found is that, on L86duntu:
- the kernel parameter enables 6 serial ports (8250.nr_uarts=6),
- stty -F /dev/ttySX (where X is in 0,1,2,3,5) is working, but in case ttyS4 it failed (no device I guess)
- can bus supported by RDC_CAN_pci and RDC_SocketCAN
- when I checked the kernel log, I can see only 3 ttyS listed:
dmesg | grep ttyS
[ 3.454994] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 3.459448] serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
[ 3.463873] serial8250: ttyS2 at I/O 0x3e8 (irq = 4) is a 16550A

2018 年 02 月 20 日
07:12:07
pongraczi
Hungary
Moderator
Forum Posts: 20
Member Since:
2015 年 02 月 11 日
Offline

Ok, it seems it is possible to enable more serial ports with
setserial /dev/ttyS3 irq 3 port 0x0260 uart 16550A baud_base 115200
setserial /dev/ttyS5 irq 12 port 0x02e8 uart 16550A baud_base 115200

2018 年 02 月 20 日
07:14:01
pongraczi
Hungary
Moderator
Forum Posts: 20
Member Since:
2015 年 02 月 11 日
Offline

Somehow, under L86duntu the test program is working as expected, but under my custom built linux and kernel, the receiver only receives some characters, most of the message is missing.
Still working on.

2018 年 02 月 26 日
05:03:30
pongraczi
Hungary
Moderator
Forum Posts: 20
Member Since:
2015 年 02 月 11 日
Offline

Unfortunately there is no breakthrough.
RS485 is working but not usable, because it messes up the message.

0,0,0
--become--> 0

firstSensor,secondSensor,thirdSensor --randomly--> fed
or fsr
etc. (more or less random, but usually starts with f)

And the number of the messages are lower on the receiver side, so, messages disappear.

The setserial and the testprogram is the same, but on L86duntu it is working, while with my custom kernels, testprogram failed as explained above.
Do you have any idea, what did I miss?

The setup seems this:
# stty -F /dev/ttyS3
speed 9600 baud; line = 0;
min = 0; time = 0;
-brkint -imaxbel
-opost
-isig -icanon -iexten -echo -echoe

2018 年 02 月 27 日
04:53:02
pongraczi
Hungary
Moderator
Forum Posts: 20
Member Since:
2015 年 02 月 11 日
Offline

There is an interesting thing:
- when I start the testprogram with strace to be able to debug, the communication is much better, only a few characters are missing.
Like this:

0,,0
0,0,0
0,0,0
0,0,0
0,0,0
0,0,0
0,00
0,0,0
0,0,0
0,0,0
0,0,0
0,0,0
0,0,0
0,0,0
0,0,0
0,0,0
0,0,0
0,0,0
0,0,0
0,0,0
firstSeo,enSeso,tirdSensor
firstSeno,cnSensor,tirdensor

Forum Timezone: Asia/Taipei

Most Users Ever Online: 50

Currently Online:
5 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Dinosaur: 27

leutenecker: 13

mrZagg: 10

tomka: 8

UIdahoCIT: 8

lukeross: 8

smeezekitty: 8

hippy: 8

Ekkehard: 8

Kato Gangstad: 7

Member Stats:

Guest Posters: 0

Members: 1467

Moderators: 14

Admins: 5

Forum Stats:

Groups: 2

Forums: 10

Topics: 226

Posts: 1068

Newest Members: Harrymet, gabrielman, chengyenwu, josearh30, p513817, ray9979, jay411335, Fut, futkc, veista

Moderators: Glaux: 70, uaa: 11, guigra: 16, asian55: 22, Android_Lin: 204, bcarroll: 12, cucubutter: 84, recycled-air: 12, stevemork: 16, zerozaber: 50, pongraczi: 20, George Andrews III: 56, poto: 11, garpastym: 20

Administrators: eveshih: 1, anthony: 31, viky6: 0, roboard: 135, hcl: 0