this is what I have so far which will display com1 data but it is all distorted I am assuming because I need to some how tell it to use the right baudrate,data bits,and stop bits.
Global ComSteam:TStream
Global recvd:String
Global data:String
Global bytes
ComSteam = OpenStream("COM1:")
If ComSteam
Print "STREAM CONNECTED on COM1"
Else
Print "STREAM FAILED TO CONNECT on COM1 "
Input()
End
EndIf
Repeat
'Print "@Recieving "+data+" byte(s)"
bytes = StreamSize(ComSteam)
DebugLog bytes + " DEBUG INFO HERE"
'Local send$ = Input("PC> ")
WriteByte(ComSteam,2)
If bytes
Local i
SeekStream(ComSteam,0)
For i=0 To StreamSize(ComSteam)-1
data = data + Chr(ReadByte(ComSteam))
Next
Print "COM1> " + data
Clean()
Else
'Print "COM1 has timed out."
EndIf
If KeyHit(ESCAPE) Then End
Forever
Function wait()
Local time = MilliSecs()
While StreamPos(ComSteam)=0
If MilliSecs()-time>1000 ' we'll give it a 1 second time out
Return 0
EndIf
Wend
Return StreamSize(ComSteam)
End Function
Function recv()
Local data$,i
SeekStream(ComSteam,0)
For i=0 To StreamSize(ComSteam)-1
data = data+Chr(ReadByte(ComSteam))
Next
End Function
Function clean()
CloseStream(ComSteam)
ComSteam = OpenStream("COM1:")
End Function
|