Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
889 Views

How to Use c_str Replacement From DiegoV_Intel on Edison ARDUINO IDE

I am trying to use the following code with my Edison and an SIM800l

void setup() {

// Set console baud rate

SerialMon.begin(115200);

delay(5000);

}

void loop() {

// Detect module baud rate

uint32_t rate = 0;

uint32_t rates[] = { 115200, 9600, 57600, 19200, 74400, 74880 };

SerialMon.println("Autodetecting baud rate");

for (unsigned i = 0; i < sizeof(rates)/sizeof(rates[0]); i++) {

SerialMon.print(String("Trying baud rate ") + rates[i] + "... ");

SerialAT.begin(rates[i]);

delay(10);

if (modem.autoBaud(2000)) {

rate = rates[i];

SerialMon.println(F("OK"));

break;

} else {

SerialMon.println(F("fail"));

}

}

if (!rate) {

SerialMon.println(F("***********************************************************"));

SerialMon.println(F(" Module does not respond!"));

SerialMon.println(F(" Check your Serial wiring"));

SerialMon.println(F(" Check the module is correctly powered and turned on"));

SerialMon.println(F("***********************************************************"));

delay(30000L);

return;

}

// Access AT commands from Serial Monitor

SerialMon.println(F("***********************************************************"));

SerialMon.println(F(" You can now send AT commands"));

SerialMon.println(F(" Enter \"AT\" (without quotes), and you should see \"OK\""));

SerialMon.println(F(" If it doesn't work, select \"Both NL & CR\" in Serial Monitor"));

SerialMon.println(F("***********************************************************"));

while(true) {

if (SerialAT.available()) {

SerialMon.write(SerialAT.read());

}

if (SerialMon.available()) {

SerialAT.write(SerialMon.read());

}

delay(0);

}

}

However, I get the following error:

'class String' has no member named 'c_str'

I have seen a possible solution from DiegoV_Intel here

However, I am not very proficient in programming with Arduino and am unsure how to implement it.

0 Kudos
7 Replies
Highlighted
Community Manager
12 Views

Hello jkkoverd,

 

 

Thank you for interest in the Intel® Edison Breakout Board.

 

 

While I was doing research, I noticed seems that the error arises if someone uses the function c_str(), but I can't seem to find it in your code. The incompatibility issue has been reported in the past.

 

 

The link that you provided showed a workaround that helped some costumers, it consists of changing the function system(fakeCommand.c_str()) with system(fakeCommand.buffer). But since you are not using the c_str() function, the error might be related to another function form the String library. Maybe the function String().

 

 

In order to provide better assistance I'll like to know what you are trying to accomplish (brief description of your project) and where did you obtained the code that you posted.

 

 

I'll be waiting for your response.

 

 

Regards,

 

Andres
0 Kudos
Highlighted
Beginner
12 Views

Hello, sorry for the late reply. I am trying to use this code to test and learn how to use the SIM800l with my Edison. I got the code from an example of a library. I don't have the computer I made this on right now so I can't check the name but it was listed as a SoftSerial alternative.

0 Kudos
Highlighted
Community Manager
12 Views

Hello jkkoverd,

 

 

Since what you are trying to accomplish is to learn more about how to use your SIM800L module with your Edison, I'll recommend you to check this site https://cristiansteib.github.io/Sim800l/, because it shows some code that uses the Sim800l.h library ( https://github.com/cristiansteib/Sim800l). This library contains a series of functions that make it easier to interact with your module.

 

 

In case there is another issue that you would like to address, don't hesitate to use this community.

 

 

Regards,

 

Andres
0 Kudos
Highlighted
Beginner
12 Views

Hello, sorry again. The example for the library you linked uses SoftwareSerial which I believe the Edison doesn't yet have support for. Do you know how or if it would be possible to change this to use hardware? Thanks.

0 Kudos
Highlighted
Community Manager
12 Views

Hello jkkoverd,

 

 

Could you please provide the link to the SoftSerial alternative you are using? While I was doing research, what I found was the AltSoftSerial, in case you haven't already checked it, here are a couple of links:

 

https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html, https://github.com/PaulStoffregen/AltSoftSerial.

 

 

You may also be interested in testing the code provided by Stan_Gifford in this thread https://communities.intel.com/thread/76476 https://communities.intel.com/thread/76476.

 

 

I'll be waiting for your response.

 

 

Regards,

 

Andres
0 Kudos
Highlighted
Beginner
12 Views

As far as I can tell there is no way to use Software Serial with the Edison. I am trying to get Stan_Gifford's code to but I am getting some errors that I'm currently trying to solve.

Build options changed, rebuilding all

idk:8: error: 'TinyGPSPlus' does not name a type

TinyGPSPlus gps;

^

C:\Users\seanm\Documents\Arduino\idk\idk.ino: In function 'void setup()':

idk:23: error: 'TinyGPSPlus' has not been declared

Serial.print("Testing TinyGPS++ library v. "); Serial.println(TinyGPSPlus::libraryVersion());

^

exit status 1

'TinyGPSPlus' does not name a type

0 Kudos
Highlighted
Community Manager
12 Views

Hello jkkoverd,

 

 

I've done more research regarding your case, and, unfortunately, there is not an easy way to test your shield with the Edison, you may need to code your own library.

 

 

There are three known libraries to communicate with another serial device: Hardware Serial, AltSoftSerial and SoftwareSerial.

 

 

Since the architecture of the Edison is different from the one present in the Arduino boards, there will be incompatibility issues in some of the libraries (not every library has been adapted to work in both boards). As you pointed out, the SerialSoftware is one of those (sorry if I mislead you in a previous post).

 

 

That makes some shields not (currently) compatible with your Edison board, in order to check the shields that have been officially tested, see this document http://www.intel.com/content/www/us/en/support/boards-and-kits/000020775.html.

 

 

Please provide the link to the original code, it may help me find a workaround to the issue.

 

 

There are a couple of threads where alternatives have been discussed, if you are interested in checking them out, here are the links:

 

https://communities.intel.com/thread/58935 https://communities.intel.com/thread/58935

 

https://communities.intel.com/thread/67707 https://communities.intel.com/thread/67707 (thread is Galileo oriented but compatible with the Edison)

 

 

Regards,

 

Andres
0 Kudos