Stick mark/space parity for RS485 support #461
Replies: 4 comments 13 replies
-
In my opinion RS485 support should be implemented in a separate class. The
class CSerialDevice is already rather complex. According to the "BCM2835 ARM
Periperals" document it's forbidden to change the parity settings in the UART
LCRH register, while the UART is enabled, but CSerialDevice is designed for
the UART being enabled all the time, when it is used. That's why implementing
the Mark/Space parity setting would make it even more complex.
|
Beta Was this translation helpful? Give feedback.
-
RS-485 support would be great to have in Circle. What I read, it is used for data acquisition systems, which I see as one interesting application for Circle. Unfortunately I'm not familiar with RS-485 and I do not have RS-485 equipment for testing. So I would need help to realize this. From Wikipedia I did read, that:
Therefore I'm a little bit unsure, what it needs to support real RS-485 applications. I can only see, that the PL011 UART description for the BCM2835 says:
This makes it complicated to add a method to the Circle serial driver, which simply changes the (stick) parity settings, while the UART is running. These setting are made in the UART_LCRH register. Thus I would prefer to add a specific class, which implements the mentioned TX block mode and switches the UART on and off, when it is necessary. To implement this more info on the protocol is required. |
Beta Was this translation helpful? Give feedback.
-
I'm about to use Pi1. Given that only UART0 is PL011, and the mini UART does not support parity, I think the RS-485 device should be UART0. I do not need to use another UART, however, it would be nice to allow the mini to be reallocated as the Circle UART. |
Beta Was this translation helpful? Give feedback.
-
After diving more into this, I want to provide the attached patch (in the .zip file), which adds the following methods to the serial driver
Please see the header file serial.h for details about these methods. I think, they should help to implement the RS-485 blocking mode, like you did for the RP2040. This patch is not tested, because I currently do not have a slave device for this purpose. This is not, what I planned before (new class(es) for RS-485 support). I realized, that there are a number of different protocols, which are used with a RS-485 physical layer, and that a lot of them are user defined protocols (not standards). I guess, your protocol is some kind of that. Because of this it seems to be impossible to me, to provide classes for the most common protocols (and for your protocol) in an amount of time, which makes sense. Furthermore I found out, that there is RS-485 support in the Linux PL011 driver too. That's why I tried, to add the necessary function to the Circle serial driver, even knowing, that I did not find this useful before. |
Beta Was this translation helpful? Give feedback.
-
Suggesting the addition of mark/space stick parity to support RS485 on the PL011 UART. Stick parity seems to be a standard feature of the PL011 UART, as reported to work on the BCM8235:
https://marc.info/?l=linux-serial&m=145706834101241&w=2
Using stick parity also assumes the UART will be used in blocking mode to transmit, given that stick parity needs to be set/reset by reinitializing before each write(). Therefore, it is necessary to detect when the TX buffer is empty.
This technique worked well on the RP2040 UART, also a PL011 device.
Beta Was this translation helpful? Give feedback.
All reactions