Hi all,
back with a new problem.
I have a service written in C# that reads RS-485 inputs from a UHF receiver.
It is using OSDP protocol, so I am sending Poll frames and reading the subsequent replies.
The point is: if I am using Windows and my PC (AMD Ryzen processor), connected with a USB/RS485 cable, everything works flawlessly.
Bringing the same exact service on the Connect 4.... the replies start to be completely nonsense.
I checked a thousand times the cables, redone multiple times from the scratch, redone by an electrician.
Nothing different... I am sending a correct Poll frame and receiving garbage.
There is something I must to on the RevPi in order to enable or configure the RS-485 port?
thankssss
Ciao
Gabriele
RS-485 issues
Re: RS-485 issues
Hi Gabriele,
maybe you can share a simplified example of your code so we can have look. First thing which comes to my mind: Correct RTS pin handling on the RS485 interface. If you use the serial interface in rs485 mode the serial subsystem should have all steps. If you're not using the interface in rs485 mode try to activate it.
Nicolai
maybe you can share a simplified example of your code so we can have look. First thing which comes to my mind: Correct RTS pin handling on the RS485 interface. If you use the serial interface in rs485 mode the serial subsystem should have all steps. If you're not using the interface in rs485 mode try to activate it.
Nicolai
-
- Posts: 7
- Joined: 16 Mar 2024, 22:31
Re: RS-485 issues
Hi Nicolai,
this is the main "loop":
... and this is the definition of the serial port object
... and this is the various values:
portName = "/dev/ttyRS485"
baudRate = 9600
parity = Parity.None
dataBits = 8
stopBits = StopBits.One
... and with the same configuration it works properly on Windows, while in the RevPi OS I don't have a proper answer when I try to read the reply after I send the POLL frame.
The wiring has been redone multiple times, by two different people, and we tried with and without the GND pin connected.
I really can't get an angle.......
this is the main "loop":
Code: Select all
private void PollReader(object state)
{
_pollingTimer.Change(Timeout.Infinite, Timeout.Infinite);
try
{
lock (_lock)
{
byte readerAddress = 0x00; // Reader address
byte sequenceNumber = _sequenceNumber;
_sequenceNumber = (byte)((_sequenceNumber < 7) ? _sequenceNumber + 1 : 5); // Cycle between 5, 6, 7
byte[] pollFrame = BuildPollFrame(readerAddress, sequenceNumber);
SendFrame(pollFrame);
byte[] response = ReceiveFrame();
if (response != null)
{
ParseResponse(response).GetAwaiter();
}
}
}
catch (Exception e)
{
_hdLogger.WriteLog(e.Message).GetAwaiter();
_logger.LogError(e.Message);
}
finally
{
_pollingTimer.Change(TimeSpan.FromMilliseconds(_readInterval), TimeSpan.FromMilliseconds(_readInterval));
}
}
Code: Select all
_serialPort = new SerialPort(portName, baudRate, parity, dataBits, stopBits)
{
ReadTimeout = 2000,
WriteTimeout = 500
};
portName = "/dev/ttyRS485"
baudRate = 9600
parity = Parity.None
dataBits = 8
stopBits = StopBits.One
... and with the same configuration it works properly on Windows, while in the RevPi OS I don't have a proper answer when I try to read the reply after I send the POLL frame.
The wiring has been redone multiple times, by two different people, and we tried with and without the GND pin connected.
I really can't get an angle.......