Pages: [1]   Go Down
Author Topic: Serial.print and the Xbee  (Read 525 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I'm using Xbees in a project I'm working on and I'm hoping to improve it.  I've been able to get everything I want functional, although I'm looking to make communication a bit more efficient because it's actually costing me performance.  From what I've read about Serial.print, it seems to be parsing everything into single bytes, which then get sent to the Xbee one at a time.  So what the Xbee sends, according to here (https://docs.zigbee.org/zigbee-docs/dcn/09-5231.PDF) {page 8}, are a lot of header/foot bytes and a single payload byte.  What I'm hoping to do is increase the size to the payload beyond one byte.  I was wondering if it's possible to instruct the Serial to send more than a single byte (which would hopefully increase the payload size on the Xbee.)  After thinking about it, I believe I can pack all of the information I need into a single 4 byte number.  Some simple modular arithmetic on the other side could then unpack this (instead of receiving one byte at a time with a deliminator and corresponding case structure.)  Any advice would be well received.

Edit: Damn Smilies
« Last Edit: April 08, 2012, 01:00:31 am by dinochomp » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18807
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I haven't used Xbee but from what I read you should certainly be able to make multi-byte payloads.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, after messing around some, I've realized there is going to be a problem on the receiving end as well.  Apparently Serial.read is restricted to reading byte by byte.  Is there some way around this?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18807
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Huh? Doesn't the Xbee library handle that? Everything on the processor is byte by byte. It's an 8 bit processor. But you can combine them.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There are no Xbee libraries, it's all hardware, you communicate with it both receiving and transmitting using Serial command Arduino libraries.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18807
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm. Well this page shows sending a multi-byte payload:

http://code.google.com/p/xbee-arduino/
Logged


Pages: [1]   Go Up
Jump to: