ReadSerialData under Android fails if more data exist

Report any Hollywood bugs here
Post Reply
plouf
Posts: 462
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

ReadSerialData under Android fails if more data exist

Post 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
Christos
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: ReadSerialData under Android fails if more data exist

Post 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...
plouf
Posts: 462
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: ReadSerialData under Android fails if more data exist

Post 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
Christos
plouf
Posts: 462
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: ReadSerialData under Android fails if more data exist

Post 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 ?!
Christos
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: ReadSerialData under Android fails if more data exist

Post 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.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: ReadSerialData under Android fails if more data exist

Post by airsoftsoftwair »

Code: Select all

- Fix [Android]: ReadSerialData() didn't return all data when requesting less bytes than were in the queue
Post Reply