Cooking Hacks Forum https://www.cooking-hacks.com/forum/ |
|
Read data from terminal and save it | Waspmote https://www.cooking-hacks.com/forum/viewtopic.php?f=19&t=20049 |
Page 1 of 1 |
Author: | carlosglez [ Wed Aug 07, 2019 1:08 pm ] |
Post subject: | Read data from terminal and save it | Waspmote |
Hello, I am trying to save data that I send from a Terminal program to Waspmote. I want to send a 2 bytes and save them in waspmote in a uint16_t variable. The problem is that I can't get what I want. I am using the following code: Code: time = millis(); while(millis()-time < 10000) { if (USB.available() > 0) { val = USB.read(); USB.print(val,BYTE); } // Condition to avoid an overflow (DO NOT REMOVE) if (millis() < time) { time = millis(); } } Note: val is a "uint16_t" variable. I mean, I understand that if I send any number between 0 and 65536 it could be save without problem in a "uint16_t" variable, isn't it? Thank you! |
Author: | libelium-dev [ Thu Aug 08, 2019 7:01 am ] |
Post subject: | Re: Read data from terminal and save it | Waspmote |
Hi, That code is correct, which error exactly do you have? Also please take a look into the RTC_7_set_waspmote_date example that manages the data introduced through the serial monitor. http://www.libelium.com/development/was ... mote-date/ Regards |
Author: | carlosglez [ Thu Aug 08, 2019 8:00 am ] |
Post subject: | Re: Read data from terminal and save it | Waspmote |
libelium-dev wrote: Hi, That code is correct, which error exactly do you have? Also please take a look into the RTC_7_set_waspmote_date example that manages the data introduced through the serial monitor. http://www.libelium.com/development/was ... mote-date/ Regards The problem is that I enter for instance "4567", after that I divide this value into two uint8_t variables like this: Code: val0 = val & 0xff; val1 = (val >> 8); After doing that I send it in this way: Code: uint8_t trama[]={SWID1,SWID0}; error = LoRaWAN.sendConfirmed(PORT,trama,2); But when I try to get again the "4567" value I don't get that, I get another different value without sense |
Author: | libelium-dev [ Thu Aug 08, 2019 1:28 pm ] |
Post subject: | Re: Read data from terminal and save it | Waspmote |
Hi, Where are you trying to get again the value? In the LoRaWAN back-end? Which value do you get? Could you please share with us the full code you are using? Regards. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |