Anyone had any luck communicating with serial port devices in PB2022? I asked a similar question a while back, and Chris offered a solution. I tried implementing that code in my pop-up window, command button cb_read:
integer li_FileNum, li_rc
string ls_zygo_reading
li_FileNum = FileOpen ( "COM2:", LineMode!, Read!, LockRead!)
li_rc = FileRead(li_FileNum, ls_zygo_reading)
if li_rc <1 then
MessageBox("FileRead Error", li_rc)
else
st_zygo.text = ls_zygo_reading
end if
FileClose(li_FileNum)
The user takes the reading from the instrument first, then clicks cb_read, so something should be available to read. FileRead always returns -1.
In old code I had a user event, ue_commnotify(unsignedlong device, longptr status) so I put the same event in my new pop-up window. In my old code, I had a user object, uo_serial_port that did all of the processing, but I'm not testing that. Just testing the FileRead operation.
MessageBox("ue_commnotify","Event triggered")
return 0
ue_commnotify is never triggered, and cb_read always returns -1 when I try to do a FileRead.
I tried putting the ue_commnotify event in the main window, customer says they don't get a response when they take a measurement, meaning the event is never triggered. If it was triggered, they would get a message. FileRead always returns -1.
Any advice or ideas on what to try next? Does anyone have a serial port object compatible with PB2022?
~~~Tracy