jpiat / arduino

112 stars 70 forks source link

not able to send new data #10

Open archiene opened 8 years ago

archiene commented 8 years ago

hi jpiat your code is too good it is working right but the problem is i am not able to transit new data i.e i have the output Hello World2 Hello world3 ..... and so on i am not able to transmit new data from the serial monitor i have not uncommented the line // Transmit_Serial. because i am not getting any output after that do you have any suggestions ??

luizmendes commented 7 years ago

Hi archiene,

It's been a couple of months, but I have a possible answer to your question, if I undrstood it correctly. If you check the code, in the Loop() function, in the following lines:

memcpy(com_buffer, msg, 11); // size of variable msg. In this case, 11.
 com_buffer[11] = i + '0' ; /
 if(write(com_buffer, 12) < 0){
      delay(10);
 }else{

You can see that in memcpy, the size is 11. That's because the variable msg holds the value "Hello World", which contains 11 characters. If you want to change the message, remember to change the size in this piece of code as well. For example, if you want to send "Hello" (5 characters), the code should be as follows:

memcpy(com_buffer, msg, 5); 
 com_buffer[5] = i + '0' ; 
 if(write(com_buffer, 6) < 0){ 
      delay(10);
 }else{

I hope this answer is useful somehow, and sorry about possible English errors.