PDA

View Full Version : FullDuplex serial over bluetooth



raptor313
09-17-2007, 09:38 AM
I have a spin stamp attached to a boe-bot which I am using for my test platform. I'm trying to connect the spin stamp to my pc using a Sparkfun BlueSmirf adaptor. I'm currently using RealTerm to check the data going back and forth. The short term goal of this project is to be able to send control signals to the boe-bot while it is sending data, ping, accelerometer, etc... back. I would like it if I could use one Cog for input and one for ouput, however I'm currently using fullduplex serial.

I want it to change the value of speed if I send it a message, otherwise I want the value of speed to be the same. Ideally I would like it so that it would not have to wait. I tried using Serial.RxCheck, however it can never pick up when I send it information. This current setup works, but it only works when the delay for Serial.RxTime(100) is 100ms or more, I need to do this a LOT faster.

Does anyone have any suggestions on how to change this code so that it will quickly change the value of speed and send it back without interrupting the flow of data back from the prop. Thanks for any help in advance.




CON
_xinfreq = 10_000_000
_clkmode = xtal1 + pll8x
debugTX = 1 '16
debugRX = 0 '17
len =8
baud = 9600
PING_Pin = 4
VAR

long Stack[1000]
word values[10]
word buffer[8]
byte buffer2[6]
byte speed
byte counter
byte Cog 'Hold ID of cog in use, if any
byte start_sending

OBJ
BS2 : "BS2_Functions" ' Create BS2 Object
Serial : "Extended_FDSerial"

PUB Start
Serial.start(debugRx,debugTx,0,9600) ' Rx,Tx, Mode, Baud
speed := "x"
repeat
if((counter := Serial.RxTime(100))+1)
byte[@speed] := counter
Serial.tx(speed)

raptor313
09-18-2007, 01:47 PM
In case anyone runs into this problem, it just had to do with the fact that the bluesmirf module was being limited by not being in ATMF mode. I had tested this theory by testing the same setup over serial cable, but I had made an error in my code. So if anyone is doing this, if you use RealTerm, you can go to the miscellaneous tab and click enter AT mode and then enter fast mode. Then send a start sequence in the send tab of "start" and have the CR checkbox sent so that you end up sending a "start" + <CR>. Here's my simple code for this setup. Also remember after it starts streaming data, unless you want a bunch of enters, uncheck the <CR> box.




CON
_xinfreq = 10_000_000
_clkmode = xtal1 + pll8x
debugTX = 1 '16
debugRX = 0 '17
len =8
baud = 57600
PING_Pin = 4
VAR

long Stack[200]
word values[10]
word buffer[6]
byte buffer2[6]
byte speed
byte counter
byte Cog 'Hold ID of cog in use, if any
byte start_sending

OBJ
BS2 : "BS2_Functions" ' Create BS2 Object
Serial : "Extended_FDSerial"
DAT
start_string byte "start",0 'need to add 0 at end for strcomp


PUB Start
Serial.start(debugRx,debugTx,0,9600) ' Rx,Tx, Mode, Baud
BS2.start
speed := "x"
counter:= 0

Serial.RxStart(@buffer)
repeat while (NOT(strcomp(@buffer,@start_string)))
Serial.RxStart(@buffer)


repeat
if((counter := Serial.RxCheck)+1)
speed := counter
Serial.tx(speed)
Serial.tx(counter)