Shop OBEX P1 Docs P2 Docs Learn Events
PropBasic: SEROUT byte array (sanity check) — Parallax Forums

PropBasic: SEROUT byte array (sanity check)

VonSzarvasVonSzarvas Posts: 3,525
edited 2010-09-20 08:41 in Propeller 1
To output a set of byte codes with serout, should this work ?
CONFIGLCD     DATA    $F0,$F0,$07,$00,$08,$00,$A6,CR,LF

SEROUT TXPIN, BAUD, CONFIGLCD

Thank you.

Comments

  • VonSzarvasVonSzarvas Posts: 3,525
    edited 2010-09-20 07:42
    ... ah, it seems the 4th byte ($00) acts as a termination, so the rest of the bytes are not transmitted...

    So I suspect my question should be, how to actually SEROUT a DATA label containing $00 ?
  • VonSzarvasVonSzarvas Posts: 3,525
    edited 2010-09-20 08:41
    I solved it by adding a routine to JonnyMac's serial lib like this:
    TX_DATA       SUB     1
    TERMINATOR    CON     $FF
    
    CONFIGLCD     DATA    $F0,$F0,$07,$00,$08,$00,$A6,CR,LF,TERMINATOR
    

    And to transmit the data label:
    TX_DATA CONFIGLCD
    

    Here is the new sub I added to the serial lib:
    '{$IFUSED TX_DATA}
    SUB TX_DATA
    
       __param3 = __param1 ' Save param as __param1 overwritten by TX_BYTE
    
       DO
            RDBYTE __param3, __param2 ' Read byte from hub
            IF __param2 = TERMINATOR THEN EXIT
            TX_BYTE __param2
            INC __param3 ' Move to next byte in hub
       LOOP
    
    ENDSUB
    '{$ENDIF}
    

    In the DATA definition, the last byte is the termination byte and not transmitted. This could be whatever you like- just change the CONstant definition.

    I hoped to use -1 as the termination byte but it fails (I guess obviously as we are talking bytes). Maybe Bean could suggest a smarter way, but for now this does the job !
Sign In or Register to comment.