Community
cancel
Showing results for 
Search instead for 
Did you mean: 
GGand2
Novice
1,318 Views

MRAA C++ UART RFID MODULE EM_18

Jump to solution

Hi, I'm new with intel Edison and I'm trying to develop a c++ application to read data received in edison's uart gpio's and write it to console (in the future the data must be filtered and sent via wifi ).

I'm working with intel Edison + Arduino breakout board and I've done all tutorials in order to flash it with last firmware, install drivers and developers kit in pc, connect to pc with tera term (microUSB serial port) and I've configured eclipse in order to deploy applications in the Edison (Hello world succesfully run).

I'm trying to run the following code :

# include

# include

# include

# include "mraa.hpp"

int main()

{

mraa::Uart* dev;

dev = new mraa::Uart(0);

std::cout<<"UART SUCCESS"<<"\n";

char array[12];

std::cout<<"Test 3";

for(;;)

{

std::cout<<"Test 1";

dev->read(array,12);

std::cout<<"Test 2";

for(int i=0;i<12;i++)

std::cout<<array[i];

}

delete dev;

return mraa::SUCCESS;

}

And none of the tests are executing ... the program prints UART success and thats it ! ... Cannot figure out what is wrong with it ! Please do help

Output :

root@edison:~# echo $PWD'>'

/home/root>

root@edison:~#

root@edison:~# chmod 755 /tmp/autopark;/tmp/autopark ;exit

UART SUCCESS

Tags (1)
0 Kudos
1 Solution
KMill10
Valued Contributor II
112 Views

You see no output because you never send a newline "\n" to std:cout

View solution in original post

8 Replies
idata
Community Manager
112 Views

Hi Goutham_Gandi,

 

 

Thank you for contacting us! We want to help you resolve this issue.

 

 

First, it's advisable that you update the MRAA packages on your board as well as on your PC so you can use the latest version of the code and the latest set of sensors supported by your host libraries. You can see information on how to do this here https://software.intel.com/en-us/node/705853

 

 

Next, we looked for that specific sensor in the list of supported sensors https://iotdk.intel.com/docs/master/upm/modules.html but, there's no specific library for this sensor. We looked at the RFID sensors categories here: https://iotdk.intel.com/docs/master/upm/group__rfid.html . In these cases, where the sensor used is not in the list of supported sensors by UPM, we'd recommend to look for a library that works with this sensor or build the library yourself and then try to add the library to ISS following https://software.intel.com/en-us/node/705855 . It's hard to know if this sensor will work on the Edison since I don't have that specific sensor to test it myself and it's not on the UPM library.

 

 

Regards,

 

-Sergio A

 

GGand2
Novice
112 Views

Thank you for the reply ... I didn't find a library for em-18 rfid reader and those existing libraries won't do either , but after reading this http://www.nskelectronics.com/em-18_rfid_reader.html EM-18 RFID READER , I thought if i connect the Tx of the em-18 reader to Rx of the breakout board and configure UART ,I can read the rfid value (12 digit Hex number ) through pin 0 .

But my program seems to exit after I configure UART on pin 0 , and there is no exception thrown .

idata
Community Manager
112 Views

Thank you for your reply. From your description, it's not clear if you're still using the code from your original post or if you're using another approach, such as http://www.nskelectronics.com/em-18_rfid_reader.html http://www.nskelectronics.com/em-18_rfid_reader.html . If you're using the code from the first reply, is "UART SUCCESS" the only message printed? "Test 3" should also be printed if I'm not mistaken.

 

 

If that's the case, then I'd recommend you to take a look at these MRAA examples of UART https://github.com/intel-iot-devkit/mraa/tree/master/examples/c%2B%2B https://github.com/intel-iot-devkit/mraa/tree/master/examples/c%2B%2B . These examples are tested and should work properly with your board. You can use them as reference and edit your code accordingly.

 

 

Keep us updated on your progress.

 

 

-Sergio A

 

GGand2
Novice
112 Views

Hi ! Thanks for the reply ... I've run this example https://github.com/intel-iot-devkit/mraa/blob/master/examples/c%2B%2B/Uart-example.cpp mraa/Uart-example.cpp at master · intel-iot-devkit/mraa · GitHub but when I use the numbered notation

(try {

dev = new mraa::Uart(0);

} catch (std::exception& e) {

std::cout << e.what() << ", likely invalid platform config" << std::endl;

}

std:: cout<<"Uart success"; )

It exits after Uart Success ... (same as before) .

#

The output is

root@edison:~#

root@edison:~# chmod 755 /tmp/autopark;/tmp/autopark ;exit

Uart successlogout

#

If I use the raw mode

(

try {

dev = new mraa::Uart("/dev/ttyACM0");

} catch (std::exception& e) {

std::cout << "Error while setting up raw UART, do you have a uart?" << std::endl;

std::terminate();

}

)

I get an exception

#

root@edison:~# chmod 755 /tmp/autopark;/tmp/autopark ;exit

Error while setting up raw UART, do you have a uart?

terminate called after throwing an instance of 'std::invalid_argument'

what(): Error initialising UART

Aborted

logout

#

Does this mean I donot have UART ?

Or should I configure it somehow ??

idata
Community Manager
112 Views

Hi guys,

 

 

@Goutham_Gandi,

 

Thank you for confirming the suggestion of @SpiderKenny worked for you. Feel free to come back to the community if help is needed.

 

 

@SpiderKenny-Thanks so much for helping out!

 

 

Regards,

 

-Sergio

 

KMill10
Valued Contributor II
113 Views

You see no output because you never send a newline "\n" to std:cout

View solution in original post

GGand2
Novice
112 Views

Funny , never thought " \n " would be the answer . Thanks a lot ! . It's solved !

KMill10
Valued Contributor II
112 Views

Goutham_Gandi I'm glad it helped!

Reply