It is possible to use Arduino SoftwareSerial or APM FastSerial with the debugger. The SoftwareSerial library is automatically included duiring compilation but to use FastSerial you must be debugging an Arduino project that includes references to FastSerial (such as ArduPilot and ArduCopter)
As an APM user, the "RemoteTransport" project property will be something you WILL need to set. Other users are not concerned with "RemoteTransport" because the default uses normal arduino hardware serial. Anyway, it's easy to setup because the options have a pick list (see below).
All of the options shown below are default except for the FastSerial setting. The configuration below will result in FastSerial on the APM upload port at a speed of 115200 baud. So, with this configuration, you can not use mission planner unless it is connected via xbee.
click the image for a draft overview tutorial
Tips...
- To use a different APM serial port such as Serial2, enter Serial2 as the "RemotePort" property
- To use a different PC serial port such as COM7, enter COM7 as the "LocalPort" property
- To switch from the default speed of 115200, set the "LocalSpeed" to value from the pick list, RemoteSpeed will change automatically to match.
- Apm users should not that the "Throttle" properties relate to debugger bandwidth throttling and are nothing to do with drones :) Leave the throttle at the defaults, learn more about the throttle via the forum.
- If using SoftwareSerial on spare digital pins you should clear the RemotePort property and set the Remote Rx Tx Pins to the digital pins that are connected to the serial device or cable. If "Break/Pause" and "Startup Wait" are not enabled (default) then only the Arduino Tx pin is required
And a few hints that might mean something at some stage...
1) Validation Skip (project property)
Set to False if you are not altering the arduino code in a way that might cause compilation errors. This will skip the "release" build of apm that happens prior to the debug build. (Saves time)
2) TracePoint Throttle (project property)
An unconditional breakpoint/tracepoint example in the 50hz loop is a good example for us to use...
By default, for newer users and non fastserial users the breakpoints are throttled so that the 50hz loop will only run at about 8-12hz. Visual micro ensures an 80 millisecond delay between breakpoints.
a)
FastSerial is more efficient than normal arduino serial so you could change the project property called Throttle (ms) to, for example, 30 (milllis) which would improve the speed. Leaving the Throttle (ms) empty uses the default of 80ms.
or b)
Try setting "Throttle Enabled = False" to entirely disable throttling in which case apm will send as fast as it can but it is possible for the arduino buffer to overflow causing the debug to stop working or invalid serial packets to be received by the debugger
or c)
Set the breakpoint "HitCount" to 50. Because we are in the 50hz loop this should produce one debug breakpoint message every second allowing apm to function at full speed inbetween each breakpoint message
or d)
Set the "Hit Counter" project property to milliseconds and all the breakpoint "HitCounters" will no longer be treated as counts, instead the HitCounts will represent milliseconds. So a breakpoint "HitCount" of 1000 would produce a debug message exactly once every second regardless of where you put the breakpoint.
IMPORTANT NOTES
When sharing the serial port with the arduino code you might expect to see some "junk" in the serial window. This is normal, the debugger windows will workaround the "junk" and function correctly. If your arduino program reads the serial port then you will not be able to switch on the break/pause facility in which case you should use a different arduino serial port or SoftwareSerial on two digital pins.
The throttle setting is very dependant on the speed of your pc. If the arduino sends messages faster than your pc can process them the pc display will fall behind the arduino. The pc display will no longer be real-time and will be confusing.