Go Down

Topic: TX command code & RX respond code of module via serial com (Read 17190 times) previous topic - next topic


mr_hacker90

Code: [Select]

byte variableParts [SOME_NUMBER][3];


when i want try to compile, it shows an error. not declare in this scope. how i want to declare it. may i have an example? so that i know how it works.


mr_hacker90


Which bit?
Subtraction or subscripting?


perhaps all i think. perhaps i can get an example on both of them. it might help to get me understand on it.

mr_hacker90


Code: [Select]
const int SOME_NUMBER = 10;


with that, can i modification on byte right? put mathematical operation on it.

AWOL

byte or int, they're both capable of arithmetic operations

mr_hacker90

with const int SOME_NUMBER = 10; how it could link with other 2 bytes?

byte variableParts [SOME_NUMBER][3]; how it would link between the [3]?

quertyn


Code: [Select]
  while(Serial.available() == 0){
    delay(10);
  }

Can you describe the exact purpose for the delay()? Does it matter whether the while loop iterates 10 times in 100 milliseconds, or 10,000,000?

If you know (or think/hope) that the response is going to be 6 bytes, wait for 6,

Then, of course, you still need to read all 6 of them.


You're right the delay doesn't really matter, I put it just to understand the need to wait.
About the wait of 6 bytes, keep in mind, for later use, the size of the buffer used by Serial library to store the received bytes, 16bytes if I remember well. Typicaly don't expect to be able to do a
Code: [Select]
while(Serial.available() < 32);

AWOL

#38
Jan 16, 2013, 03:14 pm Last Edit: Jan 16, 2013, 03:16 pm by AWOL Reason: 1
Quote
keep in mind, for later use, the size of the buffer used by Serial library to store the received bytes, 16bytes if I remember well.

You don't ;) (unless you've got very restricted RAM, like on a Tiny)

mr_hacker90


You're right the delay doesn't really matter, I put it just to understand the need to wait.
About the wait of 6 bytes, keep in mind, for later use, the size of the buffer used by Serial library to store the received bytes, 16bytes if I remember well. Typicaly don't expect to be able to do a
Code: [Select]
while(Serial.available() < 32);


with my current code now, it is working. able to add, delete, search empty the fingerprint. i made separate file coding. right now, i'm studying how i'm gonna adjust the fingerprint address according to the address i want to store the fingerprint. for add fingerprint, the last 3 bytes of the command code should be adjustable & depend on the input in the serial monitor. i'm stuck here. still trying.

AWOL

Quote
with const int SOME_NUMBER = 10; how it could link with other 2 bytes?

byte variableParts [SOME_NUMBER][3]; how it would link between the [3]?

I don't understand what you're asking here.
What do you mean by "link"?

If you've got three bytes, let's say a, b, c, and you want to store them in the second instance of "variableParts", then
Code: [Select]
variableParts [1][0] = a;
variableParts [1][1] = b;
variableParts [1][2] = c;

mr_hacker90

what i mean is link to here

Code: [Select]

byte addFingerPrint[5] = {0x4D, 0x58, 0x10, 0x03, 0x40}; // 8 bytes
byte variableParts [SOME_NUMBER][3];

Serial.write(addFingerPrint, sizeof(addFingerPrint));


how to integrate & link it with Serial.write?

AWOL

Code: [Select]
byte addFingerPrint[5] = {0x4D, 0x58, 0x10, 0x03, 0x40}; // 8 bytes
byte variableParts [SOME_NUMBER][3];

Serial.write(addFingerPrint, sizeof(addFingerPrint));
Serial.write(variableParts [someIndex], 3);

mr_hacker90

understand. should be like this. the output bytes still 8 bytes as i wanted. now, i need to do is made the variable byte become something that can be manipulate. how ya?

Code: [Select]

byte addFingerPrint[] = {0x4D, 0x58, 0x10, 0x03, 0x40}; // 5 bytes
byte variableParts [] = {0x00, 0x00, 0xF8}; // 3 bytes

Serial.write(addFingerPrint, sizeof(addFingerPrint));
Serial.write(variableParts, sizeof(variableParts));

AWOL

Quote
i need to do is made the variable byte become something that can be manipulate.

It's in RAM. You can do whatever you like with it (within the Laws of Thermodynamics)
I'm sorry, I really can't see what the problem is here. You seem to be overthinking it.

Quote
how ya?

I'm very well, thank you for asking.

Go Up