Shop OBEX P1 Docs P2 Docs Learn Events
data from serial connection to pc command line — Parallax Forums

data from serial connection to pc command line

lfreezelfreeze Posts: 174
edited 2008-11-06 22:10 in General Discussion
I would like to use the serial connection from the propeller chip to the desktop pc
To run a batch file resident on the PC C drive.· The batch file will be run when
The propeller sends serial data commands on the link to the PC. After experimenting
For Several hours with various code combination, I think that this is either, not possible,
or is beyond my skills, or requires some additional software. I did a number of
google searches and found Many commercial software packages for serial port
monitoring but none seemed· right for my purpose.· I would appreciate any
help that can be provided. Here are a few of the failed propeller code examples:
·
“filename is a variable created earlier in the program”
·
·FILENAME := STRING("%SystemRoot%\system32\cmd.exe")
·waitcnt (80_000_000 + cnt )
·FILENAME := STRING("test.bat")
·
·FILENAME := STRING("c:\windows\system32\svchost.exe")·
·waitcnt (80_000_000 + cnt )
·FILENAME1 := STRING("test.bat")· ·.
·
I am using windows xp sp2 on the desktop.
·
A sincere thank you for any help that may be provided
·
Larry

Comments

  • MSDTechMSDTech Posts: 342
    edited 2008-10-15 21:40
    You could try a Visual Basic app that reads the text in from the serial line and passes it off to the shell command in vb. I haven't used this with the free version of VB, so you may need to do some experimenting.
  • lfreezelfreeze Posts: 174
    edited 2008-10-16 00:12
    Thanks for the response. I will download vb and see if I can make make it work.
  • hippyhippy Posts: 1,981
    edited 2008-10-16 14:26
    Under MS-DOS there used to be a variant of the MODE command which would redirect command line input and output to a serial port. That may still exist in some form under Windows XP / Vista.
  • lfreezelfreeze Posts: 174
    edited 2008-10-16 16:26
    Thanks for the suggestion about the "mode" option.· I have an old MS-DOS 6.2 manual which

    gives mode a brief description. I will investigate this option. The first suggestion of developing

    a visual basic routine appears to be a working option as I am finding some examples of vb

    programs which do read serial data from the com port and take action based on the vb·program.

    I had hoped to avoid the learning process with visual basic but it seems to be the way to go.

    Larry
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-10-16 19:01
    Hi Larry, if you opt for VB over the MSDOS batch file yet don't feel like you want to get into Visual basic too much I attach a real quick and easy VB method you might try that accepts any batch file or executable as a serialized string which must be terminated with a LF or CR.

    There is not a lot of error checking and I have not had chance to try it out but it should work straight out the box. If there are problems it might need a little more code, the application form itself for instance can be hidden from the user and run in the background.

    Jeff T.
  • WBA ConsultingWBA Consulting Posts: 2,935
    edited 2008-10-16 22:24
    Don't recall exactly how it was done, but I saw this done a while back by someone else. They were using a BS2 stamp to emulate a serial keyboard. It somehow interfaced a serial barcode scanner as well. If you emulate a keyboard, you can do anything you want on the PC (even run windows apps since almost everything can be done with keyboard shortcuts). This particular setup would use an LCD to ask the operator to scan a barcode on a unit being tested, start a test program that ran from a command line on a PC, that would in turn start the functional test program/fixture. Upon pass/fail, the PC transmitted that back to the LCD for operator action.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andrew Williams
    WBA Consulting
    IT / Web / PCB / Audio
  • lfreezelfreeze Posts: 174
    edited 2008-10-17 12:07
    Thank you both for the responses. I will use the vb method provided by Jeff to back
    into learning the fundamentals of visual basic. Having ·a simple working example makes
    it so much easier. I plan on spending some time with the online vb tutorials this morning,
    hopefully it will be a useful tool to use in conjunction with the propeller. Can you suggest
    a manual that describes VB basics? ··
    Based on Andy’s response, I will do some searching of the forums to see if I can locate the
    other· process.
    ·
    Larry
    ·
    ·
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2008-10-17 13:26
    @Andrew and Larry

    That is an application I wrote years back - a crude version is available here ..

    http://forums.parallax.com/showthread.php?p=627711

    basically anything received on the serial port is converted into a keyboard scan code and injected into the keyboard buffer as if it was typed on the PC ..

    e.g. Set the ini file to your required com settings ..Run the application .. open a text doc and highlight it (top bar blue!) send some text from stamp - it appears on your text doc ... or what ever is highlighted ...even your command screen....enjoy !

    Rgds,
    John Twomey

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Those who can, do.Those who can’t, teach.

    Post Edited (QuattroRS4) : 10/17/2008 2:02:38 PM GMT
  • sylvie369sylvie369 Posts: 1,622
    edited 2008-10-17 13:51
    I learned the basics of how to do this from this site:

    http://www.theabramgroup.com/basicstamp/

    Attached is a snip of the serial port settings I'm using successfully.
    217 x 312 - 29K
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-10-17 17:02
    Hi Larry, a couple of additional links that reside in these forums

    1/ Shows how to set up a serial port, works for the Prop as well as the Stamp http://forums.parallax.com/showthread.php?p=671804

    2/ A discussion on setting up an array for communication with a Prop http://forums.parallax.com/showthread.php?p=751258

    Jeff T.
  • lfreezelfreeze Posts: 174
    edited 2008-10-17 17:30
    WOW… thank you all very much. The responses with examples provided
    More than enough for me to get a real head start on my project. All of the
    Examples were great. I had already started the VB learning process with the
    Microsoft tutorials, after looking at the post from sylvie369, I quit the
    Tutorials and used the link http://www.theabramgroup.com/basicstamp/
    I found the instruction on the link straight forward and very
    easy to follow and would suggest it to anyone attempting to interface
    Stamp or Propeller chips via the serial port.
    ·
    Larry
  • lfreezelfreeze Posts: 174
    edited 2008-10-21 20:46
    ·
    I have another question about propeller to command line programming. I have been successful
    In getting the propeller to open wordpad and download data to it (see below). My problem is
    I cannot determine how to save and close the file from within wordpad using keyboard commands.
    I think using a command line/dos based text editor may solve the problem but I am not sure which one
    To use. A quick search revealed very many free text editors. Can anyone suggest a simple one that
    Can be run using only keyboard commands?
    ·
    Thanks· again……..
    ·
    ·
    I have been using the vb program provided by QuatroRS4, it works flawlessly. I can use the
    Propeller to open wordpad and download data directly to it. ·My desktop is is running windows xp.
    I am using a serial cable to a propplug
    ·
    1. Download the following spin file to the propeller
    2. from the desktop run neokbwi.exe·· (exe and ini provided by QuattroRS4, see previous posts)
    3. open command line window
    4. ·reset the propeller
    5. wordpad should open and the test data should appear
    ·
    · Here is the spin file
    ·
    CON
    · _clkmode····· = xtal1 + pll16x
    · _xinfreq····· = 5_000_000
    'VAR
    'OBJ
    ··· ser··········· : "FULLDUPLEXSERIAL"
    ·pub Start
    ·· ser.start(31, 30, 0, 9600)
    ·· waitcnt (80_000_000 + cnt)
    ·· senddata
    pub senddata····························································
    ··· ser.str(string("cd c:\ "))
    ··· ser.tx(10)
    ··· ser.tx(13)···
    ··· waitcnt (80_000_000 + cnt)········································································
    ··· ser.str(string("cd\Program Files\Windows NT\Accessories>wordpad"))
    ··· ser.tx(10)
    ··· ser.tx(13)
    ··· ser.str(string("wordpad.exe"))
    ··· ser.tx(10)
    ··· ser.tx(13)···············
    ··· waitcnt (80_000_000 + cnt)·
    ··· ser.str(string("the quick brown fox jumps over the lazy dogs back 1234567890"))
    ··· ser.tx(10)
    ··· ser.tx(13)

    ·Thank you

    Larry
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2008-11-06 18:41
    Larry,
    Nice app. if you like I can modify the program to send multiple key strokes etc .. or write a simple editor to react to a cetain sequence of keystrokes or F buttons .. Let me know.. I also have an application which logs data received on a serial port·to a text or html file.

    You can get·it here ..
    http://www.igniteautomation.com/IA_Logger.html

    Regards,
    John Twomey

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Those who can, do.Those who can’t, teach.

    Post Edited (QuattroRS4) : 11/6/2008 6:49:54 PM GMT
  • lfreezelfreeze Posts: 174
    edited 2008-11-06 22:10
    John,
    ·
    Thank you for the link to the data logger. I haven’t downloaded it yet But will give
    it a ride later today. I think it may be just what I need. My Objective is to create an
    Application that will trigger specific text, based On the condition of various ·sensors
    connected to propeller. The text will be sent to a txt file on the desktop
    (from the propeller) via the serial link.
    ·
    The second part of the project is to get to the desktop command line again from the
    serial link (via the propeller),· and generate a command at the desktop command line.
    The command I want to generate will run a batch file. The batch file will contain
    the code to generate an email/text ·message. I know I could probably accomplish
    this with the Parallax “PINK” module, But ·I don’t want to add additional hardware
    and costs.
    ·
    This ·is the batch file, it uses BLAT software (free)
    ·
    @echo off
    ·set to=-to someone@comcast.net
    ·set from=-f anyone@comcast.net
    ·set subject=-subject "Message file attachment from Propeller"
    ·set body=-body "Message from propeller is attached"
    ·set attach=-attach "c:\program files\propeller stuff\propeller.txt
    ·set server=-server smtp.comcast.net -debug
    ·
    ·blat - %body% %to% %from% %subject% %server% %attach%
    ·
    I have gotten most of this to work with some significant help from Andy Schenk (Propterminal) Basically he created a routine which when prop terminal is opened it creates a Txt file on the desktop and writes whatever you send to propterminal to the save file.
    ·
    This works well if you want to send emails on a routine schedule. I am using windows
    Xp task scheduler to accomplish this part. I want to be able to generate email/text messages on the fly based on the condition of the various sensors connected to the
    Propeller, and eliminate the task scheduler.
    ·
    This ·is the batch file
    ·
    @echo off
    ·set to=-to someone@comcast.net
    ·set from=-f anyone@comcast.net
    ·set subject=-subject "Message file attachment from Propeller"
    ·set body=-body "Message from propeller is attached"
    ·set attach=-attach "c:\program files\propeller stuff\propeller.txt
    ·set server=-server smtp.comcast.net -debug
    ·
    ·blat - %body% %to% %from% %subject% %server% %attach%
    ·
    I used the routine you provided ·NeoKBWI.exe ·and spent some significant time With PERL software. I found that I could run compiled programs thas way but Could not do a
    line by line process. If you have a suggestion that will help with This I would really
    appreciate it.
    Thanks……
    Larry
    ·
Sign In or Register to comment.