Shop OBEX P1 Docs P2 Docs Learn Events
serial string — Parallax Forums

serial string

I have been sending out commands such as, SEROUT 13, 84, ["t0.txt=", 34, "HELLO", 34,255,255,255] on the BS2 but i am having trouble outputting the same command on the propeller. does anyone have any idea how this may be accomplished? thanks.

Comments

  • just to add i am programming with simpleIDE
  • Have a look at learn/examples/protocol/helloLCD.c for an example. Doesn't have the fancy formatting of SEROUT, though.
  • I believe print and dprint are available in SimpleText.h

    In SimpleIDE, in the menus, choose Help -> Simple Library Reference. From there look under "Text Devices" at simpletext.h

    The string you printed above would likely come out like this:

    print( "t0.txt= %s", "hello" );

    I'm not sure what the 13,84 or (34,255...) bits do.

    If you need positioning, the Parallax serial terminal does it with special characters. A screen clear is character zero, for example, so you could do it like this:

    print( "%c", 0 );
    print( "t0.txt= %s", "hello" );

    or like this:

    putChar(0);
    print( "t0.txt= %s", "hello" );
  • i have tried all of those ideas, i think my problem is with how the BS2 and propeller actually output the string.

    // SEROUT 13, 84, ["j0.val=",DEC 1, 255,255,255]

    // SEROUT 13, 84, ["t0.txt=", 34, "USM.inc", 34,255,255,255]

    here are two that work perfect on the BS2. 13 is the pin#, 84 is the baud, "j0.val=" is an identifier, DEC 1 is the actual info, and 255 255 255 is an end code i believe its received as 0xFF 0xFF 0xFF.
    i dont know how the propeller actually outputs quoted text compared to BS2.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2016-01-20 20:01
    For this you will need to use one of the slightly more advanced methods of serial communication - I don't think you can change the pin or baud for printf, print, printi, or __simple_printf.

    If you'd like to use the FullDuplexSerial backend, you can try the following code:
    #include <fdserial.h>
    int main () {
        // transmit on pin 13, receive on "-1" which i'm just using as a placeholder, 0 is the "mode", and 84 is the baudrate
        fdserial *serial = fdserial_open(13, -1, 0, 9600);
        dprint(serial, "j0.txt=%d%c%c%c", 1, 255, 255, 255);
        dprint(serial, "t0.txt=%d%s%d%c%c%c", 34, "USM.inc", 255, 255, 255);
        return 0;
    }
    

    There are other options as well, included with PropWare and libpropeller - but I suspect this will be easiest for you.

    ---- Edit
    I've fixed update the call to fdserial_open based on Electrodude's response regarding the special "84" number in the BS2 code.
  • BS2 baud constants are %oip_0000000000000 | ((1000000/baud) - 20), where o is open source/drain, i is inverted, and p is parity.

    84 is 9600 baud, not open, non-inverted, and no parity.
  • BS2 baud constants are %oip_0000000000000 | ((1000000/baud) - 20), where o is open source/drain, i is inverted, and p is parity.

    84 is 9600 baud, not open, non-inverted, and no parity.

    Thanks. Sample code updated.
Sign In or Register to comment.