Shop OBEX P1 Docs P2 Docs Learn Events
control-P as ascii text? — Parallax Forums

control-P as ascii text?

HumanoidoHumanoido Posts: 5,770
edited 2008-10-15 22:22 in BASIC Stamp
Using a BS2 and serout, how do you send a control-P as ascii text?

I'm stuck at this point, using an Emic TTS board, trying to activate the phonetic alphabet, by sending a control-P. I know how to send it as hex and this is working in hex mode. But I don't know how to send it as text using text mode. When I type a control-P from the Editor, it goes into print mode. Is there something very simple that I'm overlooking?

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-10-15 13:49
    Hi,
    programatically simulating keystrokes I would send "^P", no guarantee but you could try it.

    Jeff T.
  • HumanoidoHumanoido Posts: 5,770
    edited 2008-10-15 15:41
    I tried sending ^P and the Emic saw it as text and spoke the P but not the ^. It did not recognize it as a control-P.

    Typing the Ctrl+P goes into print mode.
    P42 • BASIC Stamp Syntax and Reference Manual
    Ctrl+P = Print current source code
    www.parallax.com/Portals/0/Downloads/docs/prod/stamps/web-BSM-v2.2.pdf

    Maybe it's impossible? Any more guru's care to take a look at it?

    Post Edited (humanoido) : 10/15/2008 4:10:29 PM GMT
    682 x 340 - 39K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-10-15 16:07
    Control-P is the "data link escape" character and has the value $10 or 16. So just send a 16 instead of a quoted character. You can also define it as a constant first, viz:

    DLE     CON 16
    
    SEROUT 1, 84, [noparse][[/noparse]DLE, "!Test"]
    
    
    


    -Phil
  • HumanoidoHumanoido Posts: 5,770
    edited 2008-10-15 16:17
    When the DLE value of 16 is sent in the serial command, in the format as shown, the emic does nothing with it. It appears that the 16 is being sent but not recognized as anything. If 16 is put into the text stream quotes, it speaks it as "sixteen."

    I'm beginning to think this is a bug in the Emic.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-10-15 16:45
    Did you try the example in the manual?

    DLE     CON 16
    
    SEROUT 1, 84, [noparse][[/noparse]"The quick ", DLE, "bw1Wn fox."]
    
    
    


    It it's still a problem, it would help if you posted some code...

    -Phil
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2008-10-15 17:08
    I use the following in an automated weather station to send, "Welcome to Mount Tamalpais":

    SEROUT 1, 84, [noparse][[/noparse]$00,"welcome to mount ",$10,"t@m@lp1YIs",$AA]
    where the commands are $00 for "say", $10 for "next word phonetic", and $AA is "end of message".

    It works fine, although the phonetic pronunciation of the word is still not quite "native".

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • HumanoidoHumanoido Posts: 5,770
    edited 2008-10-15 18:05
    Tracy Allen, I'm using the Emic with the first DIP switch in the up position for text mode instead of hex mode, so the code you list will only work if the DIP switch is moved to hex mode in the down position. Since the other command codes work well in text mode, I had hoped control-P would also work in text mode.

    Here's the main code that speaks the first sentence, but does not active the phonetic alphabet after that - the suggestions were tried and also stuff in green did not work.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    #SELECT $STAMP
    #CASE BS2, BS2E, BS2PE
    Baud CON 396 ' 2400 baud, N81
    #CASE BS2SX, BS2P
    Baud CON 1021
    #ENDSELECT
    Tx PIN 0 ' connects to Emic SIn
    Rx PIN 1 ' connects to Emic SOut
    Reset PIN 3 ' 1 = normal op, 0 = hard reset
    DLE CON 16
    x CON $10
    SEROUT Tx, Baud, [noparse][[/noparse]"say= The quick;"] ' speaking routines
    SERIN Rx, Baud, [noparse][[/noparse]WAIT ("OK")] ' wait for ok from emic then proceed
    'SEROUT Tx, Baud, x ' control P
    'SEROUT Tx, Baud, [noparse][[/noparse]"say= ^Pbw1Wn fox. ;"]
    'SEROUT Tx, Baud, [noparse][[/noparse]16,"say= ^Pbw1Wn fox. ;"]
    'SEROUT Tx, Baud, [noparse][[/noparse]x,"say= bw1Wn fox. ;"]
    'SEROUT Tx, Baud, [noparse][[/noparse]"say= 16 w1Wn fox. ;"]
    'SEROUT Tx, Baud, [noparse][[/noparse]"say= 16w1Wn fox. ;"]
    'SEROUT Tx, Baud, [noparse][[/noparse]DEC1 16, "say= ^Pbw1Wn fox. ;"]
    'SEROUT Tx, Baud, [noparse][[/noparse]"The quick ", DLE, "bw1Wn fox."]
    SERIN Rx, Baud, [noparse][[/noparse]WAIT ("OK")] ' wait for ok from emic then proceed
    STOP ' maintain processor state
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2008-10-15 19:45
    How about,

    SEROUT Tx, Baud, [noparse][[/noparse]"say=The quick ",$10,"bw1Wn fox. ;"]

    The ^P has to immediately precede the phonetically spelled word, and the phonetics end with the space that follows the word.

    Why don't you use HEX mode?

    Re: control of the EMIC from the PC keybaord. If you want to send ^P (ascii 16=$10) from the STAMPW IDE debug screen, type SHIFT-CTRL-P. CTRL-P alone as you know brings up the PC print dialog, but add the SHIFT and the IDE will send the control character instead.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • HumanoidoHumanoido Posts: 5,770
    edited 2008-10-15 22:22
    Tracy Allen said...
    SEROUT Tx, Baud, [noparse][[/noparse]"say=The quick ",$10,"bw1Wn fox. ;"]
    Exactly! Your thinking is perfect! Thanks sincerely.

    Why ASCII and not HEX Mode? The Emic commands were already defined English, in ASCII mode, and did not need to be redefined with code statements with constants. For small programs, total code lines could be few, even with some sacrifice in memory usage. HEX can sometimes be less intuitive. The text line syntax appears easier to work with. I like to have Emic return "OK" when it's ready, which is more explicable than a hex number. I wanted to write everything in ASCII and compare it to HEX. I have other application code which uses ASCII and want to combine this code with it, and have all code use the same standard ASCII for serial communications. I already had sample code for the Emic that used HEX and wanted to write the routines in ASCII mode.
Sign In or Register to comment.