Page 1 of 1
ReadSerialData under Android fails if more data exist
Posted: Tue Dec 15, 2020 12:54 am
by plouf
Hi
the following test hangs,or at least stop receiving no matter what, if you send quick more data in queue, working perfect under windows
note that it is testing WITHOUT timeout, and with FTDI proven reliable to other bug.
Code: Select all
OpenSerialPort(1, "COM18")
Repeat
CheckEvents()
Wait(1)
serdata$,count = ReadSerialData(1, 1)
Print(serdata$)
Until 0
if you send 2/3/6 character from PC nothing displayed
but if you send one after one byte it does
also under some circumenstances data do nto arrive at all, and need to resend, but i have not track down exact reason for this
Re: ReadSerialData under Android fails if more data exist
Posted: Thu Dec 24, 2020 4:44 pm
by airsoftsoftwair
Ok, I can reproduce this. Looks like an issue in the UsbSerial library that is used by Hollywood on Android to me. I've reported it here:
https://github.com/felHR85/UsbSerial/issues/323 Let's see if anyone cares to comment...
Re: ReadSerialData under Android fails if more data exist
Posted: Thu Dec 24, 2020 5:48 pm
by plouf
note that its not only byte by byte, but as you send bigger data than waiting
i..e fails also at
serdata$,count = ReadSerialData(1, 2)
if you send 3 bytes etc
btw. the project seems more or less dead in development, i doupt anyone will reply, no more to "fix" if the problem is in library

oot by maybe in topic..
https://github.com/mik3y/usb-serial-for-android , this one turns to be MIT too in last 6 months
Re: ReadSerialData under Android fails if more data exist
Posted: Sat Dec 26, 2020 1:23 am
by plouf
...however just wondering and searching. i see that an app called usb serial console (one uses this library)
https://play.google.com/store/apps/deta ... ialconsole
can display correctly in its output if you 1 or more characters from PC... so must be a way to correctly read unknown length of data correctly
how ?!
Re: ReadSerialData under Android fails if more data exist
Posted: Mon Dec 28, 2020 10:16 pm
by airsoftsoftwair
plouf wrote: ↑Thu Dec 24, 2020 5:48 pm
note that its not only byte by byte, but as you send bigger data than waiting
i..e fails also at
serdata$,count = ReadSerialData(1, 2)
if you send 3 bytes etc
Yes, this doesn't contradict my diagnosis in
https://github.com/felHR85/UsbSerial/issues/323. The error always seems to show when the data in the pipe has more bytes than the data in the buffer. I could easily fix this in UsbSerial but I'd first like to have some feedback from them, but as you said...
plouf wrote: ↑Thu Dec 24, 2020 5:48 pm
btw. the project seems more or less dead in development, i doupt anyone will reply, no more to "fix" if the problem is in library

oot by maybe in topic..
https://github.com/mik3y/usb-serial-for-android , this one turns to be MIT too in last 6 months
...maybe the project is dead
plouf wrote: ↑Sat Dec 26, 2020 1:23 am
display correctly in its output if you 1 or more characters from PC... so must be a way to correctly read unknown length of data correctly
how ?!
That app probably uses the callback-based interface of UsbSerial but Hollywood can't easily be made to use that.
Re: ReadSerialData under Android fails if more data exist
Posted: Fri Jan 22, 2021 9:55 pm
by airsoftsoftwair
Code: Select all
- Fix [Android]: ReadSerialData() didn't return all data when requesting less bytes than were in the queue