COM1 port access

BlitzMax Forums/BlitzMax Programming/COM1 port access

ckob(Posted 2008) [#1]
trying to read COM1 port to get data from a cisco switch I cannot seem to get the info in readible format.


ckob(Posted 2008) [#2]
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




jhocking(Posted 2008) [#3]
Would you be wanting the COMM module here:
http://www.nigelibrown.pwp.blueyonder.co.uk/blitz/userlibs/index.htm


ckob(Posted 2008) [#4]
well i tried that module and it doesn't seem to do anything with the above code I actually get something.


ckob(Posted 2008) [#5]
any ideas anyone? still working on this and it's driving me insane.


Does anyone have Mr.browns contact info so I can email him it is not on his site or modules.


FlameDuck(Posted 2008) [#6]
any ideas anyone?
Use Linux and the tty for the serial port instead.


ckob(Posted 2008) [#7]
i would rather use linux but that is not an option right now.


Nigel Brown(Posted 2008) [#8]
@ckob click on the name and you will get contact info


ckob(Posted 2008) [#9]
yeah I knew that but did not know your user name here guess I should of searched your name :P sent you an email.


ckob(Posted 2008) [#10]
The above code does work just not in any readable format is there a way to pass the baudrate,data bits,and stop bits once connect?


Nigel Brown(Posted 2008) [#11]
@ckob
you should check wxCTB now as this morning I had it receiving data on a MAC!


Brucey(Posted 2008) [#12]
..except it's only had 1 day development, so don't get your hopes up too much. Still lots to do.