Hello,
My problem could be related to this one : [url]https://forum.sierrawireless.com/t/possible-bug-in-rv50-serial-port-read/8645/1], but the provided answers to this post didn’t help me to fix mine.
I run an application on an RV50 that’s supposed to read data from the serial port. But the data frames that I read are wrong and don’t match with the frames I send (To be precise, it works sometimes but like 80% of the time datas are wrong and I need a 100% reliability system).
Here are pieces of my code :
In the first place, I reserve the serial port :
--------------------------------------------------------------------------------
-- Check if the serial port has been reserved for AAF --------------------------
-- if not, reserve it ----------------------------------------------------------
--------------------------------------------------------------------------------
function reserve_serial_port (string)
LOG = LOG .. "inside reserve_serial_port, string: " ..'\10'
local serial_available = devicetree.get(string)
LOG = LOG .. "inside reserve_serial_port, result to devicetree.get: " .. serial_available..'\10'
print("inside reserve_serial_port, result to devicetree.get: ", serial_available)
if serial_available ~= 1 then
local result = devicetree.set(string, 1)
LOG = LOG .. "Reserving Serial Port for AAF. Result: " .. result..'\10'
print ("Reserving Serial Port for AAF. Result: ", result)
end
LOG = LOG .. "Serial Port Reserved" .. '\10'
print("Serial Port Reserved")
end
Then I configure the serial port :
--------------------------------------------------------------------------------
-- open and configure UART ----------------------------------------
--------------------------------------------------------------------------------
function open_UART (string)
print ("Inside open_UART, string: ", string)
LOG = LOG .. "Inside open_UART, string: " .. string..'\10'
local portname
local i = 0
if string == "main"
then
portname = "/dev/ttyS0"
elseif string == "aux"
then
portname = "/dev/ttyS2"
end
print("Portname called within open_UART: ", portname)
-- Serial configuration : 19200 bauds, 8 datas bits, No parity, No flowcontrol, 2 stop bits
local serial_config =
{
baudRate=19200,
flowcontrol = 'none',
numDataBits=8,
parity='none',
numStopBits=2
}
local serialdev = serial.open(portname, serial_config)
return serialdev
end
And to finish, I read from the serial port :
function receivefromuart(uarthandle)
print("Inside synchronize")
local err
local Pointeur_Write_Buffer
while true do -- permanently read on the UART
uarthandle:settimeout (1)
local read1_buffer, err = uarthandle:read("*a") --lecture des caractères arrivant sur l'UART
if read1_buffer ~= nil then
synch_buffer = synch_buffer .. read1_buffer
print("_________________ received data is: __________________")
tohexandprint(synch_buffer)
print("______________________________________________________")
Pointeur_Write_Buffer = string.len(synch_buffer)
print ("Longeur Buffer :",Pointeur_Write_Buffer)
if Pointeur_Write_Buffer <= 24 then
LOG = LOG .. "Longeur Buffer :" .. Pointeur_Write_Buffer .. '\10'
else
checkintegrity(synch_buffer)
synch_buffer = ""
end
end
end
end
Let me know I you need more details about the code.
I run this code on many LS300 and I never had problems. I tried on 2 different RV50 for the same result, but every time what is read is not what is sent…
I tried to upgrade the RV50 firmware (4.5.0.017 -> 4.5.2.004), but same issue for both.
I also tried to change the flowcontrol setting and I have only one application on the RV50.
My settings in the Acemanager : https://puu.sh/qMIdI/f9e1d830b5.png