Hi
I have a situation where a USB cable is attached to the PC but not connected to a device. PureBasic opens the serial port but the AvailableSerialPortInput() blocks. I would have thought it would have returned with 0. I am using PB 5.45 on Linux OpenSuse 43.2. Since the AvailableSerialPortInput() blocks my application is locked with no way to continue. What happened was that a technician took the device but left the cable connected to the PC and I am looking for some way to handle this without locking up the application.
Thanks,
Simon
Why does AvailableSerialPortInput() block?
Why does AvailableSerialPortInput() block?
Simon White
dCipher Computing
dCipher Computing
Re: Why does AvailableSerialPortInput() block?
Why do I not know what you have programmed
No working example... (with the behaviour) no help.
In all my codes I have no problems with this.
No working example... (with the behaviour) no help.
In all my codes I have no problems with this.
Re: Why does AvailableSerialPortInput() block?
Hi
The following line blocks when the USB cable is left attached to the PC but no device is attached to the other end of the USB cable.
The following line blocks when the USB cable is left attached to the PC but no device is attached to the other end of the USB cable.
Code: Select all
If AvailableSerialPortInput(goParam\Mag\Port)
Simon White
dCipher Computing
dCipher Computing
Re: Why does AvailableSerialPortInput() block?
on windows 7 pro
If the device was removed while you program was running after you opened the port then
if you check for the port with "IsSerialPort()" it will tell you it is OK, even if the port is not there anymore.
Then if you try AvailableSerialPortInput() even if the device is not there you'll get a number
and I assume you do a "ReadSerialPortData()" which in fact blocks.
so the problem is how to test if device is removed.
or open the port only when you are going to read data and not at the beginning of your program.
testcode:
Norm.
If the device was removed while you program was running after you opened the port then
if you check for the port with "IsSerialPort()" it will tell you it is OK, even if the port is not there anymore.
Then if you try AvailableSerialPortInput() even if the device is not there you'll get a number
and I assume you do a "ReadSerialPortData()" which in fact blocks.
so the problem is how to test if device is removed.
or open the port only when you are going to read data and not at the beginning of your program.
testcode:
Code: Select all
If OpenSerialPort(0, "COM4", 300, #PB_SerialPort_NoParity, 8, 1, #PB_SerialPort_NoHandshake, 1024, 1024)
Debug "Success"
Else
Debug "Failed"
EndIf
MessageRequester("TEST", "Remove device")
If IsSerialPort(0) ; I WISH THIS COMMAND WOULD TEST IF THE PORT IS STILL THERE
Debug AvailableSerialPortInput(0)
Else
MessageRequester("HEY BUDDY", "Device removed no need to check for input")
EndIf
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
Re: Why does AvailableSerialPortInput() block?
Hi
I have a suspicion that problem is related to a faulty debugger. I discovered that when debugging the debugger stops on the line right after the break point when I am using the Step button in the IDE. It just so happened that the break point was the line prior to the AvailableSerialPortInput() function. This is happening at other break points as well. All the debugger buttons become grayed out. I am running PB 5.45 on linux Opensuse 43.2. The strange things is that the debugger was working earlier in the week but today it is not.
Simon
I have a suspicion that problem is related to a faulty debugger. I discovered that when debugging the debugger stops on the line right after the break point when I am using the Step button in the IDE. It just so happened that the break point was the line prior to the AvailableSerialPortInput() function. This is happening at other break points as well. All the debugger buttons become grayed out. I am running PB 5.45 on linux Opensuse 43.2. The strange things is that the debugger was working earlier in the week but today it is not.
Simon
Simon White
dCipher Computing
dCipher Computing