View Full Version : How to send variable/payload data to a serial port?
Ron
October 13th, 2002, 12:55 PM
:D Are you trying to tell me something ?
Did you try this : s=format("%c", 0x65); gives me an "e" in the string s. Take a peek at the sprintf man page here
http://unixhelp.ed.ac.uk/CGI/man-cgi?sprintf+3
With these restrictions:
Only 2 parameters (the format and the variable/value)
Parameter can either be a integer or a double
Mark F
October 13th, 2002, 12:55 PM
Add a command to the tree. In the plugins tab, choose generic serial support and press the settings key. Choose the Send data radio button and put the name of the variable in the edit field below it. Be sure to choose the correct serial port (if you use more than one). Press OK or apply.
If this doesn't work right away, you may need to change the transmit message definition to turn on/off translate (hex->bin).
Mark F
October 13th, 2002, 12:55 PM
I guess I'm confused but that is becoming more and more normal. :) Why not just set a string variable = "15"? Like this:
string Clear;
Clear = "15";
The GVMS (http://www.girder.nl/help/registers.php) function you are looking for to translate is:
format(string formatspec, integer value) converts an integer to an string. returns a string
In your case, try:
string output;
int input;
input = 0x15;
output = format("%x",input);
Mark F
October 13th, 2002, 12:55 PM
With Ron's suggestion and Francois' code we get:
string msg;
msg=format("%c",Ox15)+"Now Playing:"+format("%c",0x0D)+format("%c",0x0A)+[pld1];
Does this do what you want?
Francois
October 13th, 2002, 12:55 PM
I have a serial VFD display (BG Micro) which is not compatible with LCDriver... I can use the serial plugin to send information in hex. format (i.e., to display AB, I send '4142'...), but I would like to send some variable content (GVMS and payload from DVDSpy, etc)... How can I do this? :-?
Thanks
Eiffel
Francois
October 13th, 2002, 12:55 PM
Mark, thanks for the response...
This works... except that now, I can't send control characters anymore (i.e., 0x15h clears the display).
I tried creating two definitions for the same serial port (one with Hex->Bin, the other one without), and looked for a function to convert an ascii code into a string (for use with GVMS, as this would be ideal), but couldn't find a solution
I'm sure there's a way out, but can't find it!
Francois
October 13th, 2002, 12:55 PM
Mark,
Thanks for the help and sorry for the confusion...
A solution to my problem would be a GVMS function that translates integers into a string with the corresponding ASCII value (similar to the chr() function of the C progamming language)
This way I could send, via the serial plugin (with Hex->Bin unselected) a string such as:
string msg;
msg =chr(Ox15)+"Now Playing:"+chr(0x0D)+chr(0x0A)+[pld1];
Is there such a thing?
I did try the "%x" formatting parameter you suggested, but this doesn't seem to be the solution (probably because of my confusing request...) -- in fact if I send a string equal to 'format("%x",0x41)' to my VFD, I can't see a thing on the display (I would like to see the letter "A")
Eiffel
Francois
October 13th, 2002, 12:55 PM
While not the most elegant solution, here is a way to send both ASCII formatted text, with Girder variables, etc, and control characters to a serial port:
1. Load a program called WinTest from Crystalfonz.com (there are other alternatives such as SerialSender, but this is the only software I could find that runs at 19200bps)... this and hiding the progam on startup can be automated via Girder :wink:
2.Use a keyboard action to send your 'sentences' to WinTest instead of via the serial plugin. Like the serial plug-in, this can be used to send text with variables ([pld1], etc), but it also allows you to send non-standard control codes...
examples of sentences:
\007You got mail from [pld1] could make your VFD beep and display a customized message
\021 clears my VFD screen
there is more one can do (define custom characters, change display intensity, show special characters), etc.
Eiffel
(Now, if Ron were to add to GVMS a chr() function, all of this would not be needed... hint hint)
Francois
October 13th, 2002, 12:55 PM
I knew there was a better way!
Thanks... this is exactly what I needed
Girder is really great... :D
Eiffel
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.