Check progress of WriteSerialPortData()

Just starting out? Need help? Post your questions and find answers here.
User avatar
matalog
Enthusiast
Enthusiast
Posts: 301
Joined: Tue Sep 05, 2017 10:07 am

Check progress of WriteSerialPortData()

Post by matalog »

I am using

Code: Select all

WriteSerialPortData(1,*sbuf,16384)
to write 16384 bytes to an old computer, and I can actually list the bytes as they arrive on it.

It is the first time I am trying this with the old computer and I would like to keep an eye on it, and see if it is working correctly, once the bytes are on the old computer, then I don't really have a reliable way to get them off at the minute to check the files, so I would just like to see how far through the 16384 that I currently am on sending in PB, and compare that to where the old computer is at.

Is there any way to see how far in *sbuf that the WriteSerialPortData(1,*sbuf,16384) is at the minute?

I have been using

Code: Select all

 
  For t=0 To Lof(0)-1
  WriteSerialPortData(1,*sbuf+t,1)
  s$=Str(t+1)+"  :  "+Str(PeekA(*sbuf+t))
  Debug s$
  Delay(120)
  Next
But it will drop some bytes if the Delay is too slow, so I was hoping having a constant stream of serial data was going to be more reliable.

Any tips?
User avatar
SnowyDog
User
User
Posts: 33
Joined: Tue Jun 10, 2014 8:18 pm

Re: Check progress of WriteSerialPortData()

Post by SnowyDog »

Hello, I think you can use Result = AvailableSerialPortOutput(#SerialPort) to find out how many bytes remain in the serial output buffer.

A slightly better approach would be to use handshaking (either hardware or software) assuming that the old computer can support either.
Post Reply