Visual Studio Ide for Arduino
https://www.visualmicro.com/forums/YaBB.pl
>> >> Provide virtual COM port with debugger information stripped out
https://www.visualmicro.com/forums/YaBB.pl?num=1499854811

Message started by vmsh on Jul 12th, 2017 at 11:20am

Title: Provide virtual COM port with debugger information stripped out
Post by vmsh on Jul 12th, 2017 at 11:20am
Hello,

As I'm debugging a serial communication protocol, and the only available debugging port on my board is the one serial port I'm running the protocol on, I can't use the debugger as it interferes with my data.

It would be awesome if the debugger could create a virtual serial port used to output serial data stripped of debug information, that my host application could open and use to communicate with the board. (And obviously, the same thing would be done on the board, filtering out debugger data from Arduino's Serial.read()).

This is hackish, but it would definitely help me.

Title: Re: Provide virtual COM port with debugger information stripped out
Post by Visual Micro on Jul 12th, 2017 at 6:37pm
SoftwareSerial is supported is that helps? An ftdi cable with one (trace only) or two pins (trace/break) will work if your board supports it.

http://www.visualmicro.com/page/User-Guide.aspx?doc=Debugging-With-Different-Ports.html


Title: Re: Provide virtual COM port with debugger information stripped out
Post by vmsh on Jul 13th, 2017 at 11:28am
Thank you for the link. However, I'm already using a SoftwareSerial and a second one would take away way too many processor cycles.

Title: Re: Provide virtual COM port with debugger information stripped out
Post by Visual Micro on Jul 14th, 2017 at 4:29pm
You haven't said what hardware you have. What code on the arduino would you expect to do this?

Title: Re: Provide virtual COM port with debugger information stripped out
Post by vmsh on Jul 14th, 2017 at 11:36pm
I'm testing this on various hardware. Right now I'm having difficulties with a custom board based on the ATmega328P (same as Arduino Uno).

I'm not sure what you're asking me about the code.

Just to clear things up, this was a feature suggestion for an edge case. If this can't be done it is not really a problem, I'll just test on another board and then port the code  :)

Title: Re: Provide virtual COM port with debugger information stripped out
Post by Visual Micro on Jul 14th, 2017 at 11:50pm
Thanks for the info.

Visual micro uses standard Arduino code to send/receive data. So to implement something other than Serial or SoftwareSerial the board would have to support something else.

If you come up with any ideas I can look into them.

Title: Re: Provide virtual COM port with debugger information stripped out
Post by vmsh on Jul 15th, 2017 at 9:46pm
What I had in mind for the implementation was either hooking into Arduino's library with custom code or substituting the Serial.write() and .read() calls in compiled user code to pass through a shim implementing the filtering functionality.
(This would provide, as a side effect, a way to easily implement an escaping mechanism to avoid mixing up debug information with other data, which is something that as far as I can see is not being done now)

On the computer side I have no idea whatsoever as I don't know how VS plugins work or how your plugin works specifically. But I guess it would be easier, as the filtering functionality is already up and running for the serial console, the only thing to work out would be the virtual serial port. Afaik there are loads of products that offer OEM options with different licensing options (e.g. com0com and Eltima, if they are still alive).


This has become a bit of a flight of fancy, but I'll still post it. Maybe you can get some ideas out of it.  :)

Title: Re: Provide virtual COM port with debugger information stripped out
Post by Visual Micro on Jul 15th, 2017 at 10:27pm
It's a fair question

In most cases the debugger does split out debug packets from user println() etc.

However if the arduino code also uses serial.read then it prevents breakpoints from working correctly.

If the arduino code is just writing to the serial port it should handle things correctly if printing ascii

There is an Echo option on the serial monitor that will echo the non-debug input to another serial port.

Not sure if that helps. Obviously it's not ideal. I can't mess with underlying arduino functions such as serial so easily. They differ for each board architecture and might be prone to problems.

Title: Re: Provide virtual COM port with debugger information stripped out
Post by vmsh on Jul 16th, 2017 at 2:39pm

Visual Micro wrote on Jul 15th, 2017 at 10:27pm:
In most cases the debugger does split out debug packets from user println() etc.

However if the arduino code also uses serial.read then it prevents breakpoints from working correctly.

If the arduino code is just writing to the serial port it should handle things correctly if printing ascii


I haven't actually tried this but I suspected this was the case.
It may be over-engineering but it should definitely be possible to implement this by way of a transport protocol over serial. You could make use of already-existing Arduino abstractions to make it work without having to write too much platform-specific code. I don't see it as a problem as you're obviously already injecting code to make the debugger work. I was thinking about something along the lines of hooking all the Serial.read() and Serial.write() function calls, placing your transport layer* between those and whatever Arduino already does to read and write serial data.

*which in principle could be as simple as "the next n bytes are for [the debugger|the user's code]".

Only problem I see is that this is way too much work on edge cases stuff for a one-guy company. So, again, flight of fancy  ;) maybe one day.

Thank you for your continuous and precise responses, by the way! Awesome product and awesome communication.

Title: Re: Provide virtual COM port with debugger information stripped out
Post by Visual Micro on Jul 16th, 2017 at 3:27pm
Thanks, I am not clear about how the data will be physically transferred? What wires will be connected between arduino and pc? which arduino pins would be used?

Title: Re: Provide virtual COM port with debugger information stripped out
Post by vmsh on Jul 16th, 2017 at 4:58pm
The data would be physically transferred through the only serial port available, that would at this point be used for programming, debugging and exchanging data between the Arduino code and the user's PC program.

I made you a drawing!

https://www.dropbox.com/s/3ulziiynjwn0xy8/2017-07-16%2017.22.41.jpg?dl=0

When compiling code with "Debug" target, you change every debugger-injected code's Serial.write(...) to TransportLibrary.write(TYPE_DEBUG, ...) and every user program code's Serial.write(...) to TransportLibrary.write(TYPE_USER, ...). This function would encapsulate whatever payload it's given into an hypothetical transport header (see drawing) that would indicated whether the payload has originated from code that the user has written or code the debugger has generated.
At this point, on the computer side, the debugger is attached to the serial port, and receives the header and the payload. It de-encapsulates and demultiplexes i.e. if the header had TYPE_DEBUG it keeps the payload and processes it exactly as it does now and if it had TYPE_USER it prints it on the serial console/relays it, depending on the settings, exactly as it does now.

The same principles apply the other way: what's typed into the serial console or received by the "relay" serial port is encapsulated with TYPE_USER, what's written by the debugger for the injected code on the Arduino is encapsulated with TYPE_DEBUG, and on the Arduino Serial.read(...) calls are replaced by TransportLibrary.read(TYPE_whatever, ...) which de-encapsulates and demultiplexes Arduino's receive buffer into two separate debug & user buffers and returns the data from the right one depending on the TYPE parameter.

Title: Re: Provide virtual COM port with debugger information stripped out
Post by Visual Micro on Jul 16th, 2017 at 5:11pm
When sending from the arduino the debugger I think it already does as you described. It pulls it's own data out of any serial packet and then shows the remainder in the terminal. It works best if your own serial code uses a println() to terminate packets.

For the sending from pc to arduino I can't see how we could leave your own data on the serial inbound buffer yet get a debug continue from the buffer. It might be possible but it's a ring buffer on the serial and handled differently for each board type.

Visual Studio Ide for Arduino » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2019. All Rights Reserved.