O
O
OlejanJa2020-08-20 11:54:15
C++ / C#
OlejanJa, 2020-08-20 11:54:15

How to write a C driver for Raspberry Pi UART to communicate with devices via RS485?

Good afternoon!
Faced with the task - to interrogate devices via the RS485 interface using the Raspberry Pi. To do this, you must use a UART with a transmission mode of 9 bits in a package (the 9th bit is used for addressing devices).
Please tell me how to write a driver for hardware communication via UART for Raspberry Pi. Or where to look to deal with this issue. Previously, I had no business with the Raspberry Pi - now I'm dealing with it. But I would appreciate any information.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
edo1h, 2020-08-20
@edo1h

you don’t need to write a driver, I added MARK / SPACE support to the driver many years ago (although you could do without it by switching ODD / EVEN as needed, but ...)
in new raspberries, by default, mini UART looks out, which does not know how 9 bit, and a full-fledged UART (ttyAMA0) is occupied by bluetooth, this is configurable, more details here:
https://www.raspberrypi.org/documentation/configur...
after that there is nothing raspberry-specific in this task, we have a regular full-fledged UART , which can do 9 bits.
it remains to write / take a ready implementation of RS-485. I'm sure that Google on request "CMSPAR RS-485" will give a bunch of examples / implementations in different languages.

S
StyleBender, 2020-08-20
@StyleBender

One and two
In general, there is quite a lot of information on this subject in these your Internets. Or is there some specificity in your task?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question