Pages: [1]   Go Down
Author Topic: How many bytes can Arduino UNO handle  (Read 142 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I am trying to send different size of byte from one end to another via Xbee and Arduino UNO. There are 2 Xbee+arduino uno; one is sending, another one is receiving. What I am seeing during sending out the data is, whenever I am sending 128 byte, it is received fully and accurately. But when I am increasing it to 256 or 384, the data it is receiving is still 128 byte. I am changing the buffer in receiver part from 128 to 256 to 384 but still all it is showing is 128 bytes. May I know what is the maximum byte of data one arduino uno can handle please?
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 220
Posts: 13836
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


PLease post your code so we can see what happens.

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 34488
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
am trying to send different size of byte from one end to another
No bytes are alway the same size, they are eight bits long.

The Xbee sends buffers worth of data. A buffer is 128 bytes so if your packet is longer than this it is split up into two or more packets. You must join those packets at the recieve end.
Logged

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

Thanks to both of you. Sorry for the late reply.

@Grumpy_Mike: 128 byte buffer size makes sense. But let me clarify my query a little more elaborately with code so that it will be easier for me. Actually I am trying to send encrypted data from one node to another in AT mode. Here I refer XBee+Arduino UNO as node. Now, when I am sending 128 byte of data encrypted, the other end can decrypt all of it and shows in serial monitor. But when I am sending 256 byte of data, the other end can encrypt 128 byte and does not decrypt the other 128 byte. So, in serial monitor it is showing: 128 byte of decrypted data+128 byte of encrypted data. Please be informed that for encryption and decryption purpose I am using RC4.

simplified code for sender:
Code:
#include <string.h>
unsigned char S[256];
char has[512];

void rc4_function (){
 //required calculation for RC4
}

void setup(){
  Serial.begin(9600);
}

void loop(){
  char key[] = "01234567890";
  char data[] = "ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890";//256 byte
  rc4(key,data);
  Serial.print("Encrypted : ");
  Serial.println(has);
  delay(15000);
}

simplified code for receiver:
Code:
#include <stdio.h>
#include <string.h>
String readSer;
unsigned char S[256];
char has[512];
char key[] = "01234567890";

void rc4_function(){
  //required rc4 calcuation
}
void setup(){
  Serial.begin(9600);
}

void loop(){
    while (Serial.available()) {
    delay(2);
    char c = Serial.read();
    readSer += c;
              }
    if (readSer.length() >0) {
    char dataSer[256];
    readSer.toCharArray(dataSer, 256);
    rc4(key,dataSer);
    Serial.println(has);
    delay(15600);
 } 
  }

Now by separating packet with 128 byte limit, do you mean I should encrypt 128 byte of data 2 times and send? Not very familiar with programming, so in receiver side should I read the data one by one [i.e. first 128 byte, then 2nd 128 byte] and concatenate them together later?

Thank you for your reply.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 34488
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It is hard to tell without seeing all your code.

Quote
do you mean I should encrypt 128 byte of data 2 times and send?
No.
Send the 256 bytes but on the receive side you have to wait until a byte is in before you read it. It is hard to see with what you have posted it looks like the delay 2mS is not long enough for the second buffer. Remove the delay altogether and only read a byte when serial available tells you there is data to read.
Logged

Pages: [1]   Go Up
Jump to: