Libelium is offering new technical support channels, to contact with de Technical Support team to solve any issue our doubt please contact with your sales agent or visit our contact site



Post a new topicPost a reply Page 1 of 1   [ 4 posts ]
Author Message
 Post subject: Read data from terminal and save it | Waspmote
PostPosted: Wed Aug 07, 2019 1:08 pm 

Joined: Thu May 23, 2019 12:21 pm
Posts: 12
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!


Top
 Profile  
 
 Post subject: Re: Read data from terminal and save it | Waspmote
PostPosted: Thu Aug 08, 2019 7:01 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
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


Top
 Profile  
 
 Post subject: Re: Read data from terminal and save it | Waspmote
PostPosted: Thu Aug 08, 2019 8:00 am 

Joined: Thu May 23, 2019 12:21 pm
Posts: 12
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


Top
 Profile  
 
 Post subject: Re: Read data from terminal and save it | Waspmote
PostPosted: Thu Aug 08, 2019 1:28 pm 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 4 posts ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use.