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) Serial Monitor - Send "non-printable char" or "pure" unsigned bytes (Read 20515 times)
Irakandjii
Junior Member
**
Offline


Posts: 13
Joined: Aug 31st, 2015
Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Oct 29th, 2015 at 2:13pm
Print Post  
Hi
I would like to be able to send "pure" byte sequences to the serial port on the Arduino, to test a communication protocol.
I need to include the first 32 characters on the ascii set.  I am actually using them for their original purpose... "go figure"   Grin

I don't seem to be able to do this now.  The feature would be appreciated.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #1 - Oct 29th, 2015 at 2:18pm
Print Post  
Hi,

You need to use Serial.write not Serial.print

The terminal monitor in visual micro will not display the bytes.

Is this what you wanted to know?
  
Back to top
WWW  
IP Logged
 
Irakandjii
Junior Member
**
Offline


Posts: 13
Joined: Aug 31st, 2015
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #2 - Oct 29th, 2015 at 2:28pm
Print Post  
Thank you but,  I want to be able to use the Serial Monitor to send "packets" to the Arduino that include non-printable ascii codes  for example:
HEX        0x01 0x02 123 0x03 0x1E 0x02 255 0x03 0x17 0x04
ascii        SOH  STX         ETX  RS     STX        ETX   ETB  EOT

Some way to send a sequence of HEX would be fine
  
Back to top
 
IP Logged
 
Irakandjii
Junior Member
**
Offline


Posts: 13
Joined: Aug 31st, 2015
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #3 - Oct 29th, 2015 at 2:36pm
Print Post  
I have also found a few cases where my code was not responding "correctly" to data from other sources like I2C and some external serial devices. 

For example: 
To debug my code it would be easier to redirect the I/O and  mimic the IC2 with the console.  Once my code works, redirect back to IC2 and I would have sectionalized the problem.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #4 - Oct 29th, 2015 at 3:13pm
Print Post  
You can use the arduino type property with Serial.print(myVar,HEX)

or if you are using the debugger the watch expressions also support the same type

{myVar,HEX}

Does this help?
« Last Edit: Oct 29th, 2015 at 3:13pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Irakandjii
Junior Member
**
Offline


Posts: 13
Joined: Aug 31st, 2015
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #5 - Oct 29th, 2015 at 4:18pm
Print Post  
Not really.  The idea is to get an arbitrary 8 bit HEX sequence into the Arduino from the "Serial Monitor".  

Serial.print(myVar,HEX) prints a HEX value out from the Arduino to another device.

I need to send HEX into the Arduino from another device.  In this case, my development computer using the Serial port via the "Serial Monitor".  The Arduino reads it and takes action.

The Serial Monitor application sends HEX (unsigned char) to the Arduino on the serial port and the Arduino reads it with Serial.read().  

By way of illustration:
To embed HEX in a Visual Studio's C++ string you would use escape sequences.   https://msdn.microsoft.com/en-us/library/6aw8xdf2.aspx

You embed a hex value in a string by using /xnnn in the string, where nnn is the hex literal value.  

The string -> "This is a null /x000.  This is a BELL /x007.\n"

Would ring a bell and print the phrase: 

This is a null .  This is a Bell.

>
or 

/x022 /x048 /x069 /x021 /x022  would print "Hi!"


In the old VT100 days we could embed hex with ESC[000~ if I remember correctly.  

  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #6 - Oct 29th, 2015 at 4:20pm
Print Post  
Oh okay I understand. You can use a different serial terminal for that.
  
Back to top
WWW  
IP Logged
 
Irakandjii
Junior Member
**
Offline


Posts: 13
Joined: Aug 31st, 2015
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #7 - Oct 29th, 2015 at 4:35pm
Print Post  
Oh and thank you for the quick responses. Smiley
  
Back to top
 
IP Logged
 
Irakandjii
Junior Member
**
Offline


Posts: 13
Joined: Aug 31st, 2015
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #8 - Oct 29th, 2015 at 4:37pm
Print Post  
Ok, can you recommend one?  I use putty and it is character by character, nor does it support hex 00 to 1F.

Thanks
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #9 - Oct 29th, 2015 at 4:43pm
Print Post  
I have heard of people using realterm

Not sure if it does what you want:-

http://sourceforge.net/projects/realterm/

If you can find a solution let me know and I will add support for some special commands to the terminal

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


Posts: 13
Joined: Aug 31st, 2015
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #10 - Oct 29th, 2015 at 5:00pm
Print Post  
The reason I felt this would be good fit for Visual Micro lies in the very nature of our work.

The Hex codes 00 thru 1F were generally reserved for hardware interpretation (by the modem).  Arduino is hardware, so the support of low value hex sequences makes sense in the IDE.

ACK, NAK, XON, XOFF to name a few,  are all very useful in protocol stacks dealing with slow, noisy unreliable networks that characterize the maker space.  To test / diagnose failover protocols, we need to send these codes.  I was hoping Serial Monitor would do this.

If there is another terminal emulator out there that can do this I would appreciate a link. 

Thanks for your time
  
Back to top
 
IP Logged
 
Irakandjii
Junior Member
**
Offline


Posts: 13
Joined: Aug 31st, 2015
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #11 - Oct 29th, 2015 at 5:07pm
Print Post  
OK. Thank you so much this terminal will do fine Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #12 - Oct 29th, 2015 at 5:07pm
Print Post  
Thanks, it's useful to have someone who knows what they are talking about.

What syntax can you suggest or controls would feel comfortable to use when entering serial messages into the vm terminal?

« Last Edit: Oct 29th, 2015 at 5:09pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Irakandjii
Junior Member
**
Offline


Posts: 13
Joined: Aug 31st, 2015
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #13 - Oct 31st, 2015 at 4:07pm
Print Post  
If it was me, I would go with the Microsoft Visual Studio C++ Standard  for "embedded" literals.  It is in the link I posted earlier. https://msdn.microsoft.com/en-us/library/6aw8xdf2.aspx  ;


Reasons:
  1. Should be familiar to your user base, VS C++
  2. The syntax would work for any unsigned char value from /x000 through to /x0FF 
  3. Should be simple to parse in the "Monitor code".  
    I have not looked but there may be parser code already in the public domain
  4. The standard also provides a framework for additional types that may make sense to implement
  

I would implement the parser as a function call once the send button was pressed, basically it would copy all normal ascii/utf-8 characters as entered <current mode> when it sees an escape sequence the appropriate "unsigned char" would be inserted (copied into) into the stream.

Also, Realterm works.  It is not the simplest to use and is a bit of overkill, but having it takes the pressure off.

I hope this helps
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #14 - Oct 31st, 2015 at 5:47pm
Print Post  
Great thanks. That will be fun
  
Back to top
WWW  
IP Logged
 
Irakandjii
Junior Member
**
Offline


Posts: 13
Joined: Aug 31st, 2015
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #15 - Nov 1st, 2015 at 2:51pm
Print Post  
Oh I made a bit of an error yesterday.  
for Hex you only need 2 digits /x00 to /xFF, the leading 0 is redundant and makes the parser more difficult.

You could implement with a simple switch function.  I have included the following for inspiration purposes only.  There may be better / more efficient ways.

unsigned char *buffer = "Any character stream";

   while ( c = *buffer++ )   // Walks user input string from "monitor" until end of string
   {
      // look for and "deal with escape sequence"
      if (c == '/')
      {
            c = *buffer++  // throw out the leading '/' it is a token
            switch ( c )
           {
              case '/':
                 - this is a real slash we are done so concatenate to the output string for the UART           
                 break;
              case 'x':
                 - this is a hex number, read the next 2 chars,  concatenate the appropriate (unsigned char) to the output string for the UART              
                break;
             case ' ...  other case statements for escape sequences  you want to implement

              default:
                 - this is a regular unsigned ascii char just concatenate to the output string for the UART 
                 - Not sure if the default is desirable, it basically throws out the '/' and moves on, it might be better the throw an exception
      }   // end of "deal with escape sequence"

      - Normal unsigned char so concatenate 'c' to output string
   }

-  Send the output string to the UART 


Best regards, Irakandjii
  
Back to top
 
IP Logged
 
Irakandjii
Junior Member
**
Offline


Posts: 13
Joined: Aug 31st, 2015
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #16 - Nov 1st, 2015 at 2:55pm
Print Post  
Good lord I did not explicitly mention, the above pseudo code does not do any range or error checking.   

eg. -> Like what if the '/' is the last char at the end of the input string.   

I thought that would just get too verbose.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial Monitor - Send "non-printable char" or "pure" unsigned bytes
Reply #17 - Nov 1st, 2015 at 11:12pm
Print Post  
No probs, thanks very much it's a big help.

I notice realterm has an activeX interface.  maybe it's possible to just use a simpler part of it within visual micro but something tells me a simpler solution will be better Smiley
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint