Rank: Member
Groups: Registered
Joined: 7/25/2015(UTC) Posts: 17
|
Is it possible to use, for example, Serial.print() in a custom node?
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/11/2014(UTC) Posts: 661
Thanks: 1 times Was thanked: 81 time(s) in 76 post(s)
|
Yes you can. You might have an issue in connected mode though because while you are using Embrio the computer is communicating with the Arduino using serial.print. Your Serial.Prints might interfere with that communication, but it might not. Anyway it doesn't really make sense to use them in design mode because you can just see the data in the UI, but they do work fine in a compiled program.
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 7/25/2015(UTC) Posts: 17
|
That makes sense but how can the the code tell if it's in design/connected mode or compiled?
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/11/2014(UTC) Posts: 661
Thanks: 1 times Was thanked: 81 time(s) in 76 post(s)
|
On the bottom left of the screen is a serial connection control. When the plug icon is "connected" and the status is "good connection", that means you are communicating with an Arduino, and Embrio should be updating with live data. Use the little icon that looks like a microchip to upload a final program (this is only possible with a full license), and the program is uploaded to run entirely on the Arduino. This tutorial video might help.
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 7/25/2015(UTC) Posts: 17
|
No, I meant 'how does the arduino code know that it's connected.
eg.
if (!connected()) Serial.println("This won't mess with the Embrio comms');
How do I implement 'connected()'?
Regards, Mark
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/11/2014(UTC) Posts: 661
Thanks: 1 times Was thanked: 81 time(s) in 76 post(s)
|
That's a good idea! There's nothing like that yet. I guess for now you'll have put a flag in your custom arduino nodes and make sure to set the value correctly. I like the idea of a global flag so your arduino code knows if it is compiled mode. I'll add that to the list.
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 7/25/2015(UTC) Posts: 17
|
Hi Just a thought. I often use a scheme where I use a different character at the start of a line to signify what the line is. eg 'D' for data, 'S' for status, '#' for debugging (comment). If you were to adopt this mechanism, it would be easy for interacting programs to filter out the relevant data.
(Oh, and you might need a thread safe Serial.print).
:)
Mark
|
|
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.