Everything is working OK. The application has no user surface, so to end the program, I have included the following code.
Code: Select all
If Not IsSerialPort(0)
End
EndIf
What is wrong?
Code: Select all
If Not IsSerialPort(0)
End
EndIf
Code: Select all
*buffer = AllocateMemory(1024)
OpenSerialPort(0,"COM5",9600,#PB_SerialPort_NoParity, 8, 1, #PB_SerialPort_NoHandshake, 1024, 1024)
Repeat
Debug "Error" + Str(SerialPortError(0))
Delay(1000)
Until 0
This is for sure no bug, IsSerialPort() only tells you if a #ComPort has been successfully opened.drahneir wrote:I think its a bug with the IsSerialPort() command. When the commport isn't existing anymore, as the device manager proves, the command shouldn't say its ok.
BTW, my commport is Prolific.
Code: Select all
Procedure CallBack_NewDevice(WindowID, Message, wParam, lParam) ;add/delete live connecting USB devices (windows only)
Protected Result, ComPort.s
Protected *db.DEV_BROADCAST_HDR
Result = #PB_ProcessPureBasicEvents
Select Message
Case #WM_DEVICECHANGE
Select wParam
Case #DBT_DEVICEARRIVAL
*db = lParam
If *db\dbch_devicetype = #DBT_DEVTYP_PORT
ComPort = PeekS(*db + SizeOf(DEV_BROADCAST_HDR))
Debug "New COM Port: " + ComPort
EndIf
Case #DBT_DEVICEREMOVECOMPLETE
*db = lParam
If *db\dbch_devicetype = #DBT_DEVTYP_PORT
ComPort = PeekS(*db + SizeOf(DEV_BROADCAST_HDR))
Debug "Com Port Disconnected: " + ComPort
EndIf
EndSelect
EndSelect
ProcedureReturn Result
EndProcedure
OpenWindow(0, 0, 0, 250, 150, "Live COM Ports", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowCallback(@CallBack_NewDevice(), 0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow