I am having trouble figuring out how to receive serial data via COM1. I have searched theforum but have yet to find
anything that will help me. For academic purposes I modified Comm.bas (PB/Dll sample program) so that a known string
of bytes would be sent whenever the "Send Text" button is pressed. (code from modified comm.bas follows)
I compiled this code and moved it over to a different machine sitting less than 2 feet away.The two machines are connected
together via a 9-pin null-modem cable (2-3, 3-2, 5-5). (The cable works fine when using HyperTerminal between the machines
at 9600)
The "receiving" machine is running the following:
This set-up started out being much more complicated. But even after reducing it to what you see here, I still can't get it
to work. What I expected was for the ASCII values of "02, 04, 05, 06, 17, 30, 39, 41, 46" to show up in the "%MesgBox"
TextBox after pressing "Send Text" on the machine running Comm.bas . What I get, after pressing "Send Text" on theComm.bas
program 12 times (sometimes 11, sometimes 13), is "ÿÿÿÿÿÿÿÿÿ". On the surface it certainly looks like a baud rate is one
of the problems; among some of the things that I've tried is lowering the baud rate down to 300 (on both machines of
course). I have checked and re-checked the port settings and they are correct. About the only thing that is even slightly
encouraging is that there are 9 of the ÿ's showing up.
If it makes any difference, when the academics are over the "real" program will be sending and receiving binary data.
Thanks for taking the time to read this. Any help would be much appreciated.
Wesley Brown
------------------
anything that will help me. For academic purposes I modified Comm.bas (PB/Dll sample program) so that a known string
of bytes would be sent whenever the "Send Text" button is pressed. (code from modified comm.bas follows)
Code:
>>> CALLBACK FUNCTION Send_Callback() AS LONG >>> >>> COMM Send #hComm, CHR$(02, 04, 05, 06, 17, 30, 39, 41, 46) >>> >>> FUNCTION = %TRUE >>> END FUNCTION
together via a 9-pin null-modem cable (2-3, 3-2, 5-5). (The cable works fine when using HyperTerminal between the machines
at 9600)
The "receiving" machine is running the following:
Code:
>>> ' Create A "Listen" Thread To Monitor Input From Console >>> Thread Create ReceiveData(hDlg) To hThread& . . . >>> Function ReceiveData(ByVal hWnd As Long) As Long >>> Dim DataIn As String >>> DataIn$ = "" >>> >>> While IsFalse ThreadClose >>> If (Comm(#hComm, RxQue) < 9 ) Then >>> Sleep 1 >>> Iterate Loop >>> End If >>> >>> Comm Recv #hComm, 9, DataIn$ >>> Control Set Text hDlg, %MesgBox, DataIn$ >>> >>> Wend >>> Function = %TRUE >>> End Function
to work. What I expected was for the ASCII values of "02, 04, 05, 06, 17, 30, 39, 41, 46" to show up in the "%MesgBox"
TextBox after pressing "Send Text" on the machine running Comm.bas . What I get, after pressing "Send Text" on theComm.bas
program 12 times (sometimes 11, sometimes 13), is "ÿÿÿÿÿÿÿÿÿ". On the surface it certainly looks like a baud rate is one
of the problems; among some of the things that I've tried is lowering the baud rate down to 300 (on both machines of
course). I have checked and re-checked the port settings and they are correct. About the only thing that is even slightly
encouraging is that there are 9 of the ÿ's showing up.
If it makes any difference, when the academics are over the "real" program will be sending and receiving binary data.
Thanks for taking the time to read this. Any help would be much appreciated.
Wesley Brown

------------------
Comment