Shop OBEX P1 Docs P2 Docs Learn Events
PC Command Console — Parallax Forums

PC Command Console

Areal PersonAreal Person Posts: 197
edited 2008-06-13 18:25 in Propeller 1
Hi,

I’m working on a Propeller project where I need to create some kind of
windows software that would provide a proprietary command console to the Propeller.
It would be a window screen that would open on the PC and would have a command prompt,
I would then be able to type custom commands and they would execute on the propeller based on
how I had programmed the Propeller spin/asm program to execute the commands.

There would also need to be some communications back from the Propeller to the PC
to report command success etc...

What would be the best way to do this ? Is there any programs or resources available
that I could start with ?

I thought about just using a terminal setup to the propeller, would this be the best way ?
Is there an example that could get me started communicating with the Propeller through
a serial terminal interface etc. ? I'm new at this stuff and really need an example
to get me started.

I need to build something custom so that I can extend it with new commands and features
as I upgrade the hardware components with new features.

Thanks for the help,
-Areal

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I have a tree growing out of my head, but

what do you expect ? I'm a programmer.

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2008-06-07 22:26
    To start off with, may I suggest you use the PST (Propeller Serial Terminal) as it will function with the Prop Tool. This will share the same I/O pins as you download with.· There are an output window and an input window in PST. Use the FullDuplexSerial object in the propeller.

    Once this works, then you can write your own windoze interface. Remember DTR resets the propeller if you use the PropPlug.

    P.S. You can't use Hyperterminal on the same COM Port because it will reset the propeller by DTR (unconfirmed).

    Enjoy cool.gif
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-06-07 23:07
    Hello Areal,

    the basic thing to use is the FullDuplexSerial-object
    but i would prefer the extended fulduplex serial-object as this one provides
    commands for sending and receiving decimal numbers as a string and convert
    the string into an integervalue.

    depending on how complex the commands are
    for simple commands it might be more effective
    to translate the commands in a bytecode in the windows program and then
    send the bytecodes to the propeller.
    Otherwise you would have to receive complete strings on the propeller and compare the received strings
    with predefined strings which is surely possible.

    Simply start playing with the Extended_FD_serial-object

    you're welcome to as as many questions as you like. Concrete questions - even if they are very simple - are most apreciated
    Simple questions are simple to answer to and can be done "on the fly" so don't hestiate to ask.

    best regards

    Stefan
  • Areal PersonAreal Person Posts: 197
    edited 2008-06-08 00:42
    FullDuplexSerial-object looks like the way to go.

    I would like to implement a professional cmd console that I could
    easily extend. It needs to be high speed as possible and also be designed
    so that it can be extended with new features/commands.

    What about using the byte code design for all commands, I’m really not sure how to
    do that. What about the pros and cons ? What would a byte code command structure look like ?

    Your thoughts ?

    Also, Is there any examples of using the FullDuplexSeral object as a command
    interface ?

    -Areal

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I have a tree growing out of my head, but

    what do you expect ? I'm a programmer.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-08 01:15
    Make up commands based on the data each command might need. A command "C" might need to have two numbers that can each fit in 2 bytes, so you'd just start the command with the letter "C" followed by 2 x 2 byte values, probably least significant byte first. If the "E" command only needed a single 1 byte value, you'd start the command with the letter "E" followed by a 1 byte numeric value as a single byte.
  • Areal PersonAreal Person Posts: 197
    edited 2008-06-08 02:03
    Can I use pins 28 - 31 for the command console interface with the FullDuplexSerial-object?

    If so, I think I may have enough info to try to get started.

    Thanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I have a tree growing out of my head, but

    what do you expect ? I'm a programmer.
  • SpinHeadSpinHead Posts: 28
    edited 2008-06-08 02:39
    Not with Proptool ATM but here goes


    CON
       serRXpin       =   31
       serTXpin       =   30
       serMode        =   0
       serBaud        =   19200
    main
    
    serial.start(serRXPin,serTXPin,serBaud) 
    
    'do a loop here to pull from the serial object and write to a local buffer
    
     if(StrSize(@myBuffer))
    if(myBuffer[noparse][[/noparse]0]==82) 'R - reset controller
      DoReset()
      myBuffer[noparse][[/noparse]0] := 0 ' dont need to do this since the prop is reseting, but hey :)
    elseif(myBuffer[noparse][[/noparse]0]==120) 'x - set x value
        if(StrSize(@myBuffer)>=4) 'we will take a value of x000 to x255
          if( (47 < myBuffer[noparse][[/noparse] 1 ] < 51) AND (47 < myBuffer[noparse][[/noparse] 2 ] < 58) AND (47 < myBuffer[noparse][[/noparse] 3 ] < 58) ) ' 0 to 299 , could do more checking but not worth it
            nValue := 0
            nValue := nValue + ((myBuffer[noparse][[/noparse] 1 ]-48)*100)
            nValue := nValue + ((myBuffer[noparse][[/noparse] 2 ]-48)*10)
            nValue := nValue + ((myBuffer[noparse][[/noparse] 3 ]-48)*1)
            x := nValue 
          ELSE ' value FAILED!
            myBuffer[noparse][[/noparse]0] := 0
            serial.str(string("COMMAND FAILED"))
     
        else ' do nothing the buffer does not hold all of the data yet
    
          
      
    
    



    that should quickly get you rolling along the right path
  • Areal PersonAreal Person Posts: 197
    edited 2008-06-08 05:12
    Thanks so much friend [noparse]:)[/noparse]

    -Areal

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I have a tree growing out of my head, but

    what do you expect ? I'm a programmer.
  • BradCBradC Posts: 2,601
    edited 2008-06-08 05:25
    Another data point for you to look at.. I posted this code a while back.

    This is a Thermostat that has a PC console (via USB) and allows data logging, Setpoint/data updates/status queries and debugging dumps via a "serial terminal"
    The Parsing code is pretty ugly, but it allows single character commands + multiple integer parameters (any number in any order)

    http://forums.parallax.com/forums/default.aspx?f=25&m=216870&g=218666#m218666
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-06-08 07:43
    Hello,

    bytecommands means: you type a command like "SETPARAMETER1 100" on the PC-keyboard
    (in this case 17 strokes on the PC-keyboard. The WINDOWS-Software translates the command
    "SETPARAMETER1" to a Number between 0 and 255 that could be transmitted as ONE byte
    so this number is the bytecode. If you need more than 256 different commands you would
    translate it into two bytes (numbers between 0-65536 and should be really enough)

    without translation you would send "SETPARAMETER1 100" and on the propellerside you
    1.) receive "SETPARAMETER1" as a string
    2.) have to compare the full string "SETPARAMETER1"
    which will need more bytes and a bit more complicated programming than just comparing one or two bytes

    to keep the overview and to keep things clear on the propeller yu will define CONSTANTS for all the numbers

    example
    CON
      SetParameter1 = 103
    
    
    
    



    now you can use the word SetParameter1 for the number 103
    the propeller gets a number but you read a clear word in the text of code
    that's what constants are for.

    To extend this is up to you. If you wrote write very concrete WHAT KIND of commands you thinking of
    we can give you more advice.

    About the Pins:
    as the manual says:
    PIN 30,31 is used by the Propeller-IDE to send the program

    Once the program is sent you can use the Pins like all other Pins

    PIN 28,29 is used for the eprom through the bootphase of the chip
    after the bootphase you can use them like all other pins

    For a simple serial connection TWO pins is enough one for sending one for receiving

    Now it depends on the real application if it is enough to connect PC and propeller via a normal serial cable
    for an enviroment with a lot of electrical noise or distances ore than 5 meters other things are nescessary

    best regards

    Stefan
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-06-13 18:25
    Hi, you may find this link useful http://forums.parallax.com/showthread.php?p=671804

    Although it refers to the BS2 it is suitable for any of the Parallax processors. I am a novice with the Prop but managed to put together a Propellor app and a VB app with two way communication at 115200 baud. On the VB side a value or values are typed into any of the six text boxes, when the send button is pressed the six bytes are transmitted to the Prop which then sends them back to be displayed in the top text box. The Data_Array in the Spin code can be used internal to the Prop

    This is only an example and has no code to trap the following errors #1 Numbers less than 1 or greater than 255 #2 Closing the port while the Prop is still transmitting data

    I would normally use the sixth byte for a checksum but did not in this case. It is possible to assign any of the six bytes to switches·, sliders or indicators, whatever you want you interface to look like.

    If anyone can answer for me why sending a zero value to my current Spin code produces errors I would apprecitate it.

    Comments welcome and source code available to any who want.

    Jeff T.
    382 x 414 - 28K
Sign In or Register to comment.