Go Down

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

mr_hacker90


Quote
how ya?

I'm very well, thank you for asking.


haha.. i'm sorry. it is not that i want to ask how about u. just the meaning "ya" at my place is same like "erh" something like that. a tone asking question actually. sorry for the misunderstanding. haha.

yup. i'm overthinking. coz i dont know how to put a variable in order to change the byte accordingly to the fingerprint address.

mr_hacker90

i don't know how to make the increment formula actually i think. increment formula for the byte. increment by one byte. how many the increment in depend on the user input the fingerprint address. i think so. like that. that's the one that i stuck.

Code: [Select]

byte high = {0x00};
byte low = {0x00};
byte checksum = {0xF8};



for (int n=0; n<798; n++)

AWOL

I'm sorry, this is beyond me now.
Where did the value 798 magic itself from?
What are the variables "high" and "low" meant to be?

quertyn


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)


I was not so wrong  ]:D, took this in HardwareSerial.cpp:

Code: [Select]
// Define constants and variables for buffering incoming serial data.  We're
// using a ring buffer (I think), in which head is the index of the location
// to which to write the next incoming character and tail is the index of the
// location from which to read.
#if (RAMEND < 1000)
 #define SERIAL_BUFFER_SIZE 16
#else
 #define SERIAL_BUFFER_SIZE 64
#endif


In your case it's working because you are in the case where buffer size is 64.

mr_hacker90

#49
Jan 16, 2013, 04:37 pm Last Edit: Jan 16, 2013, 05:04 pm by mr_hacker90 Reason: 1

I'm sorry, this is beyond me now.
Where did the value 798 magic itself from?
What are the variables "high" and "low" meant to be?


the last 3 bytes. 3rd last byte is for highbyte of the fingerprint reader address. 2nd last byte is for lowbyte of the fingerprint address. while the last byte is the checksum. 798 is the total fingerprint address that the reader can store.

Code: [Select]

byte high = {0x00}; // high byte of the fingerprint address
byte low = {0x00}; // low byte of the fingerprint address
byte checksum = {0xF8}; // checksum


the address 0, is above. but, for address 1.

Code: [Select]

byte high = {0x00}; // high byte of the fingerprint address
byte low = {0x01}; // low byte of the fingerprint address
byte checksum = {0xF9}; // checksum


while for address 2,

Code: [Select]

byte high = {0x00}; // high byte of the fingerprint address
byte low = {0x02}; // low byte of the fingerprint address
byte checksum = {0xFA}; // checksum


continously until 768 address. sorry. not 798. 768 fingerprint address. total fingerprint address that the fingerprint reader can store. i believe it is related to the Serial.available as i will key in the fingerprint address.

Code: [Select]

Serial.print("Please choose fingerprint address number to store");

while(Serial.available()){

input = Serial.read;

high = high + input;
low= low + input;
checksum = checksum + input;
}

// write the 8bytes array of the command code
Serial.write(addFingerPrint, sizeof(addFingerPrint));
Serial.write(high);
Serial.write(low);
Serial.write(checksum);
}


until here. then i stuck a little bit. coz the input from serial monitor is ASCII. while i'm using bytes. how i'm gonna convert the ascii into byte in arduino?

AWOL

Quote
I was not so wrong  smiley-twist, took this in HardwareSerial.cpp:

Yes, and how many Arduinos does that apply to?

quertyn


Quote
I was not so wrong  smiley-twist, took this in HardwareSerial.cpp:

Yes, and how many Arduinos does that apply to?

I don't know. But I think it's better to be aware of the under layer limitation even if it's seems large.

Arrch


until here. then i stuck a little bit. coz the input from serial monitor is ASCII. while i'm using bytes. how i'm gonna convert the ascii into byte in arduino?


That depends. What format are you trying to key it in as (Decimal, Binary, Hex, etc.) and how many characters are being sent? Are you always sending the same amount of characters for each value, or does the number of characters sent vary?

mr_hacker90

as i key in from serial monitor arduino. i key in ASCII. then, when i want to make an increment, supposed to be that the key in value is converted into byte. to add with my formula for the byte.

Arrch


as i key in from serial monitor arduino. i key in ASCII.


Yes, you can't key it in any other way with the Serial Monitor, but you have to define what the ascii characters mean. Does "10" mean 10 or 2? Does "30" mean 30 or 48? Does "fruit cup" mean 0 or 666?

mr_hacker90

why can't? by the way, is it need to define? can just arduino program automatically convert the input ascii code to byte?

Arrch

If you're not going to bother answering my question, I'm not going to bother to respond.

mr_hacker90



as i key in from serial monitor arduino. i key in ASCII.


Yes, you can't key it in any other way with the Serial Monitor, but you have to define what the ascii characters mean. Does "10" mean 10 or 2? Does "30" mean 30 or 48? Does "fruit cup" mean 0 or 666?


actually, i only get half. don't understand the other half actually. it is not that i'm don't want to answer your question.

Arrch

You are putting characters into the Serial Monitor and expecting the Arduino to understand how to convert them to a number. You have to define whether the Arduino interprets those stream of characters as binary, hex, decimal, or some crazy custom encoding scheme.

mr_hacker90


You are putting characters into the Serial Monitor and expecting the Arduino to understand how to convert them to a number. You have to define whether the Arduino interprets those stream of characters as binary, hex, decimal, or some crazy custom encoding scheme.


understand little bit. is true that like this?

Code: [Select]

byte input = 0; // for incoming serial data
byte addFingerPrint[] = {0x4D, 0x58, 0x10, 0x03, 0x40}; // 5 bytes
byte high = {0x00}; // 1 high byte
byte low = {0x00}; // 1 low byte
byte checksum = {0xF8}; // checksum

void setup() {
  Serial.begin(57600); // opens serial port, sets data rate to 9600 bps
}

void loop() {
       
  // send data only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming byte:
    input = Serial.read();

    // say what you got:
    //Serial.print("I received: ");
    //Serial.println(input, DEC);
   
    high = high + input;
    low= low + input;
    checksum = checksum + input;
   
    Serial.write(high);
    Serial.write(low);
    Serial.write(checksum);
  }
}


by the input still yet ASCII although i already defined the input as byte.

Go Up