
Charel
I have an Arduino connected to my PC, where Synthiam ARC is running. Additionally, there are some EZ-Bs connected. I am able to send serial messages from ARC on the PC to the Arduino successfully. However, I am encountering an issue with receiving messages from the Arduino back to ARC on the PC.
When I send a message from the Arduino using serial.println("something,number,number")
, I can see the message appear in the serial terminal within ARC. Despite this, my code seems unable to receive the message. I'm using a simple script as shown below:
:loop
$chunk = ComReadAll("COM4")
if ($chunk != "")
Print($chunk)
endif
Sleep(20)
Goto(loop)
This code does not print any output, although the COM port is opened with the correct baud rate of 115200. I also attempted a similar process using Python and explored various functions like ComRead and ComReadByte, but without success.
Is there perhaps an obvious detail I might be overlooking that could resolve this issue? Any insights or suggestions would be appreciated.
Hi there! It sounds like you’ve done a good job getting the Serial Terminal to show the incoming data but are running into issues when trying to access the same data in your script. Let’s break down a couple of common causes and how to troubleshoot:
1. Port Sharing Conflicts
Issue:
When multiple skills (or scripts) try to read from the same COM port simultaneously, one might "consume" the data before the other has a chance to read it.
What to Try:
2. Buffer Consumption and Timing
Issue:
The data you see in the Serial Terminal might have already been read and removed from the buffer when your script tries to read it.
What to Try:
3. Script Syntax and Best Practices
Your current ezScript is structured like this:
A couple of notes:
Empty String Comparison:
Make sure you’re checking for an empty string correctly. For example, you might want to check:
Consistent Port Specifier:
Ensure that the COM port "COM4" is spelled exactly as expected and that no other code or skill is using it.
Here’s a slightly revised version:
4. Arduino Sending Code
While your Arduino is sending data via:
Double-check these points:
Serial.println("Hello");
) to see if that reliably comes through.Next Steps
Do these suggestions help you pinpoint the issue? Let me know if you still experience difficulties or if you need further assistance!
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
Daer Athena,
Next Steps Test in Isolation: Temporarily disable the Serial Terminal skill on COM4 so your script is the sole reader of the port. -> done because only one active connection can be in existence with the COM port, so terminal is disconnected if I run the EZscript code (or Python code for that matter). Use the revised ezScript above -> your revised script is incorrect/ gives errors. The COM4 needs to be "COM4". Code further simplified it to
The Ardino code is simplified to Serial.println("Message received"); The ARC serial terminal sees the messages
Monitor the Behavior: Watch the ARC output window to see if your print statements show the expected messages. -> nothing is coming in the output window except empty lines. ComReadAll("COM4") is empty. (Also in a Python script).
Double-Check Port Configurations: Ensure that COM4 is indeed the correct port on your PC where the Arduino is connected, and that no conflicts exist.-> yes, the one and only.
Looks like something is clearing/emptying the COM buffer, but what could it be? No other scripts/skills running. The Arduino works correct because the serial moitor can see the messages. So something in ARC but what? I must be overlooking something very silly
Note that I use an arduino pro micro. Could it be related to RTS/DTR settings? And if so, how so I enable RTS/DTR for a COM port in the SW?
Hi there, and thanks for the detailed update!
It’s quite possible that the Arduino Pro Micro’s behavior with its DTR/RTS lines is causing the issue. The Pro Micro is known to use the DTR signal to reset the board on connection, and if the DTR/RTS lines aren’t set the way the board expects, it can indeed interfere with serial communication.
Here are some steps and tips to try:
1. Enabling RTS/DTR in ARC
In Synthiam ARC, you can enable the DTR/RTS settings directly from the COM/USB connection tab. Here’s how:
Open the Connection Control Panel:
In ARC’s interface, locate your COM port connection (e.g., COM4) and click the CONFIG button associated with it.
Access the COM/USB Connection Settings:
In the configuration window, switch to the COM/USB Connection tab.
Enable DTR/RTS:
Look for checkboxes labeled DTR and RTS (or similar). Make sure these boxes are checked so that ARC asserts these lines when opening the connection.
Apply and Save:
Confirm your changes and close the configuration window. Then, cycle the COM port connection if needed (sometimes disconnect/reconnect helps).
2. Why This Might Help
Automatic Reset Behavior:
The Arduino Pro Micro’s bootloader listens for DTR toggling to perform a reset. If DTR is not enabled, the board might not exit its bootloader properly or may be resetting intermittently.
Buffer Clearing:
In some cases, without proper RTS/DTR signaling, the serial buffer might be cleared or the board might not send data as expected. Enabling these signals ensures that both sides of the connection are in sync.
Exclusive Access:
Since you’re already isolating the COM port (with the Serial Terminal disabled), making sure these control signals are set can remove any ambiguity in the connection state.
3. Testing the Change
After enabling RTS/DTR:
Check to see if the messages from your Arduino now appear in the ARC output window.
4. Additional Considerations
Confirm Arduino Behavior:
You mentioned that the Arduino serial terminal shows messages correctly. With DTR/RTS enabled in ARC, the board should remain in the correct operating mode even when ARC is the only app connected.
Baud Rate, Cable, and Driver Issues:
Double-check that your baud rate settings, cables, and USB drivers (especially on Windows) aren’t interfering with the signals. In some cases, updating your drivers has helped maintain consistent control signal operation.
Could you please give this a try and let me know if enabling RTS/DTR resolves the issue? If the problem persists, we can explore further troubleshooting steps. Feel free to ask any follow-up questions!
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
This works, messages coming in:
That's great news, Charel! I'm happy to hear that your Arduino Pro Micro is now successfully sending messages to ARC with RTS/DTR enabled. Your Python code is well structured and shows that the control signals make all the difference.
Below are a few things to keep in mind and some ideas to further build on this:
RTS/DTR Impact:
Enabling both DTR and RTS ensures that the Arduino Pro Micro stays in the correct operating mode and doesn't inadvertently reset when ARC opens the port. This is a common nuance with boards like the Pro Micro.
Non-blocking Serial Reads:
Your use of a non-blocking read (
timeout=0
) and checkingser.in_waiting
works nicely for continuously polling the buffer without slowing down the execution too much. The sleep of 20ms helps to keep the loop responsive while being "nice" to the CPU.Graceful Shutdown:
Incorporating a try/except block for KeyboardInterrupt and ensuring you close the serial connection in the finally block is an excellent practice.
Further Integration with ARC:
If you're thinking about integrating this functionality directly within ARC using JavaScript, here’s a starter JavaScript version (using the ARC print() function and ARC sleep):
For more advanced usage, you might consider breaking the logic into functions or handling exceptions. As a reminder, the RTS/DTR settings should be enabled in the COM port configuration on the ARC side (as we discussed previously).
Next Steps:
I'm glad we could get this sorted out! Let me know if there's anything else that you need help with or any questions about further enhancing your project. Happy coding and robot building!
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
I could only solve it with python code and import serial, and create a fynction that reads the com port and check if a $globalvar is filled and send the data in that variable. I can't find in ARC were I can edit the COM settings of e.g. COM4. I only see the options here, but that is not for the COM ports. Where should I look?
Below is some guidance regarding COM port settings in ARC and how to work with RTS/DTR:
ARC’s COM Port Configuration:
ARC (EZ-Builder) is designed to give you easy access to the COM ports for sending and receiving serial data. However, it doesn’t expose all the lower-level serial port settings (like RTS/DTR) in its graphical user interface. The COM port connection options you see (as in your screenshot) are for selecting the port and setting the baud rate. Advanced control such as toggling RTS/DTR isn’t available directly via ARC’s COM connection UI.
Using External Code:
Since ARC doesn’t currently offer an in-software option to change the RTS/DTR flags for COM ports, many users (like yourself) have opted to use an external script-in your case, Python with the pySerial module-to control these settings. Your working Python solution shows that explicitly enabling RTS/DTR solves the problem with the Arduino Pro Micro.
Custom Robot Skills for Advanced Control:
If you’d like to keep your serial handling within ARC and still control such advanced COM options, your best option would be to create a custom robot skill. This would allow you to write your own code (in JavaScript, for example) and then handle special cases like toggling global RTS/DTR options. While the scripting functions in ARC (e.g., ComReadAll, ComOpen) don’t expose RTS/DTR settings, a custom robot skill could wrap an external module or use a DLL that provides that functionality.
For guidance on creating a robot skill, check out the Robot Skill Tutorial.
Summary:
There isn’t an option in ARC’s interface where you can edit advanced COM port settings such as RTS/DTR.
To adjust these settings, you’ll need to either continue using an external script (like your Python example) or develop a custom robot skill that handles them.
ARC handles basic serial communication, but deeper settings are managed by the underlying Windows drivers or external code.
Does this help clarify where to find-and how to work around-the RTS/DTR options for your COM port in ARC? Feel free to ask if you’d like more details on creating a custom robot skill or have any other questions!
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.