' call and response serial example for BX-24. ' This example waits for a byte on the incoming serial connection, ' and checks to see that the byte equals 65. ' It then sends the values of three sensors on pins 13, 14, and 15. ' serial RX is on pin 12 ' serial TX is on pin 11 dim adc1Var as byte dim adc2Var as byte dim adc3Var as byte dim inByte as byte dim gotaByte as boolean dim inputBuffer(1 To 13) As Byte dim outputBuffer(1 To 10) As Byte sub main () ' set up serial port: call defineCom3(12,11,bx1000_1000) call openQueue(inputBuffer, 13) call openQueue(outputBuffer, 10) call openCom(3,9600,inputBuffer, outputBuffer) do ' read sensors: adc1Var = cByte(getADC(13)\4) adc2Var = cByte(getADC(14)\4) adc3Var = cByte(getADC(15)\4) ' read serial data in: if statusQueue(inputBuffer) = true then call getQueue(inputBuffer, inByte, 1) ' if you got the message from director, send out data: if inByte = 65 then call putQueue(OutputBuffer, adc1Var, 1) call putQueue(OutputBuffer, adc2Var, 1) call putQueue(OutputBuffer, adc3Var, 1) end if end if loop end sub