Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) Provide virtual COM port with debugger information stripped out (Read 8011 times)
vmsh
Junior Member
**
Offline


Posts: 16
Joined: Jul 9th, 2017
Provide virtual COM port with debugger information stripped out
Jul 12th, 2017 at 10:20am
Print Post  
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.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12070
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Provide virtual COM port with debugger information stripped out
Reply #1 - Jul 12th, 2017 at 5:37pm
Print Post  
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-Por...

  
Back to top
WWW  
IP Logged
 
vmsh
Junior Member
**
Offline


Posts: 16
Joined: Jul 9th, 2017
Re: Provide virtual COM port with debugger information stripped out
Reply #2 - Jul 13th, 2017 at 10:28am
Print Post  
Thank you for the link. However, I'm already using a SoftwareSerial and a second one would take away way too many processor cycles.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12070
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Provide virtual COM port with debugger information stripped out
Reply #3 - Jul 14th, 2017 at 3:29pm
Print Post  
You haven't said what hardware you have. What code on the arduino would you expect to do this?
  
Back to top
WWW  
IP Logged
 
vmsh
Junior Member
**
Offline


Posts: 16
Joined: Jul 9th, 2017
Re: Provide virtual COM port with debugger information stripped out
Reply #4 - Jul 14th, 2017 at 10:36pm
Print Post  
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  Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12070
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Provide virtual COM port with debugger information stripped out
Reply #5 - Jul 14th, 2017 at 10:50pm
Print Post  
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.
  
Back to top
WWW  
IP Logged
 
vmsh
Junior Member
**
Offline


Posts: 16
Joined: Jul 9th, 2017
Re: Provide virtual COM port with debugger information stripped out
Reply #6 - Jul 15th, 2017 at 8:46pm
Print Post  
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.  Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12070
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Provide virtual COM port with debugger information stripped out
Reply #7 - Jul 15th, 2017 at 9:27pm
Print Post  
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.
  
Back to top
WWW  
IP Logged
 
vmsh
Junior Member
**
Offline


Posts: 16
Joined: Jul 9th, 2017
Re: Provide virtual COM port with debugger information stripped out
Reply #8 - Jul 16th, 2017 at 1:39pm
Print Post  
Tim@Visual Micro wrote on Jul 15th, 2017 at 9: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  Wink maybe one day.

Thank you for your continuous and precise responses, by the way! Awesome product and awesome communication.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12070
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Provide virtual COM port with debugger information stripped out
Reply #9 - Jul 16th, 2017 at 2:27pm
Print Post  
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?
  
Back to top
WWW  
IP Logged
 
vmsh
Junior Member
**
Offline


Posts: 16
Joined: Jul 9th, 2017
Re: Provide virtual COM port with debugger information stripped out
Reply #10 - Jul 16th, 2017 at 3:58pm
Print Post  
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.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12070
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Provide virtual COM port with debugger information stripped out
Reply #11 - Jul 16th, 2017 at 4:11pm
Print Post  
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.
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint