Communication Protocol - Help!
computer guy
Posts: 1,113
Hi Everyone,
I have a serial device connected to my propeller (Easy Bluetooth Module). I have started writing an object to interface with it and have it so that I can issue a command and read the response, however the Easy Bluetooth Module sends a lot of messages to the propeller without the propeller first issuing a command.
i.e. When another bluetooth device connects to the easy bluetooth module, it tells the propeller that there is an incoming connection.
My problem is, how do I get it receiving both messages and reacting acordingly?
Working
Unknown
I have attached my code for reference.
This is urgent, if anyone can solve this problem for me I will owe them.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
Post Edited (computer guy) : 4/19/2010 11:15:20 AM GMT
I have a serial device connected to my propeller (Easy Bluetooth Module). I have started writing an object to interface with it and have it so that I can issue a command and read the response, however the Easy Bluetooth Module sends a lot of messages to the propeller without the propeller first issuing a command.
i.e. When another bluetooth device connects to the easy bluetooth module, it tells the propeller that there is an incoming connection.
My problem is, how do I get it receiving both messages and reacting acordingly?
Working
Prop------>EB (Set Name "test") Prop<------EB (Name has been set to "test")
Unknown
Prop<------EB (Incoming connection from F9:62:01:A0:17:00)
I have attached my code for reference.
This is urgent, if anyone can solve this problem for me I will owe them.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
Post Edited (computer guy) : 4/19/2010 11:15:20 AM GMT
Comments
BT.Send_Data(string("Test"))
BT.Read_Real_RSSI
You can do this by using fdx.rxcheck or making a new fdx.rxavail which does not take the character from the buffer. FDX will be receiving your string and you need to check for it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
How accurate will that be? What if the EB module sends a "incomming conection" message just after you issue a "set name" command?
Also, I would like the rx command to be in a seperate cog and continuously reading the rx buffer.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
Without more information about what you are trying to accomplish it is difficult to make any specific suggestions.
I am wanting to have access to most features of the Easy Bluetooth module.
At the moment my biggest fear is missing a "Connection droped" message from the EB and still sending data. I will essentially need a "re-connect" function.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
After that, I am hoping the rest will come easily.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
I see one problem though, what if $03 or $02 is in the middle of a packet?
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
As for those bytes appearing in the middle of a packet, one would hope not. In my packets, they can as the data bytes are $00 to $FF but the byte after the start byte is the number of bytes in the packet, so if that doesn't point to $04 at the end of the packet then the packet is invalid and is discarded and the code goes back to waiting for a start byte. Is there such a protocol for Bluetooth packets?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller
Post Edited (Dr_Acula) : 4/19/2010 2:36:09 PM GMT
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
Post Edited (computer guy) : 4/19/2010 2:52:22 PM GMT
However, you are not doing synchronous transmission so it does not really matter. Could you use the basic Xmodem protocol?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
I still can't understand why cognew isn't working. :-(
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
I have a quick question though.
With full duplex serial, if I receive $1F how do I then transmit this as "$1F" (string) to the serial line?
Thank you
edit: I have it almost working now!!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
Post Edited (computer guy) : 4/20/2010 3:39:42 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
Any ideas?
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
Post Edited (computer guy) : 4/22/2010 11:05:07 AM GMT
Where's a link to the protocol spec? I'm guessing that the length segment (like a CRC segment) is probably subject to a somewhat different set of rules than packet body text. That is not unusual.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--RvnPhnx
I tried changing:
to
but that just made things worse for unknown reasons.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
The usual program sequence would be:
read a character, compare it to $02, and set the "start of packet" flag if it is $02 - once the flag is set do not check for $02
read and save/process the header data (length, type, etc.)
read and save as many characters as specified by length and calculate crc - $00 - $FF are valid characters in this block
read and save/process the trailer
read the next character and compare it to $03 - error if not $03
check received crc (if any) and set error if not matching calculated crc
Maybe you can make better sense of this and assist me with the packet receiving code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
A state machine is very simple. In your case you have a repeat loop which reads bytes from the interface. You start with state := 0, which means FIND START DELIMITER.
It's a good idea to define some constants to make the code more readable:
FIND_START_DLM = 0
READ_HEADER = 1
CHECK_CHECKSUM = 2
READ_DATA = 3
FIND_END_DLM = 4
Now you'd use a case statement which has some code for each of those constants. For example
Post Edited (MagIO2) : 4/22/2010 1:05:44 PM GMT
I think I can put this into practice with a few modifications and filling in the blanks.
Will give me a much cleaner piece of code and better functionality.
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE
The length character tells you how long the packet is so the $03 is not a problem because you know what you are looking for. You just have to work through a block receiving the characters into a buffer.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz