SEROUT - SERIN IN ZBASIC
Posted: 29 May 2011, 7:56 AM
I've been searching for how to Communicate With Easy Bluetooth Module all day but I can't make it work.In Basic Stamp I was working with SERIN AND SEROUT with success.
What I want to do is send some bytes to the module and after that receive some more bytes. The Modules RX pin is 5 And the TX pin is 7.
I tried the following:
Unfortunately I can't get Channel 3 work.
After Setting Up Com I want to send a request message to module as above then wait until transmiting and recieving bytes end and read the inQueue array.
Thanks In Advance
I Hope
What I want to do is send some bytes to the module and after that receive some more bytes. The Modules RX pin is 5 And the TX pin is 7.
I tried the following:
Code: Select all
Function SetupConnection() as bit
Call DefineCom(3,PIN_RX,PIN_TX,0,&H1F)
Call OpenQueue(inQueue,SizeOf(inQueue))
Call OpenQueue(outQueue,SizeOf(outQueue))
Call OpenCom(3,9600,inQueue,outQueue)
if ((StatusCom(3) AND &H02) = &H02) then
SetupConnection = 0
else
SetupConnection = 1
End if
'On Error Return 1
End Function
Code: Select all
Function SearchDevice() as bit
'Send Search Request
Call PutQueueByte(outQueue,B_STX)
Call PutQueueByte(outQueue,B_REQ)
Call PutQueueByte(outQueue,GAP_INQUIRY)
Call PutQueueByte(outQueue,&H03)
Call PutQueueByte(outQueue,&H00)
Call PutQueueByte(outQueue,B_REQ+GAP_INQUIRY+&H03)
Call PutQueueByte(outQueue,&H03)
Call PutQueueByte(outQueue,&H00)
Call PutQueueByte(outQueue,&H00)
Call PutQueueByte(outQueue,B_ETX)
'Get Comfirm And Devices
'Wait Until Transmit Ends
Do while ((StatusCom(Channel) AND &H04) = &H04)
Delay(0.2)
Loop
Call GetQueue(inQueue, rByte, 1)
SearchDevices = 0
End Function
Thanks In Advance
I Hope