Shop OBEX P1 Docs P2 Docs Learn Events
FullDuplexSerialPlus methods — Parallax Forums

FullDuplexSerialPlus methods

ke4pjwke4pjw Posts: 1,173
edited 2010-03-07 04:24 in Propeller 1
Is there a method in FullDuplexSerialPlus for receiving a single byte at a time? I need to capture binary serial data that may not have a CR in the packet. Is FullDuplexSerialPlus the best object to do this? Should I create my own method to do this?

Thanks in advance,
Terry

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-- Terry

Post Edited (ke4pjw) : 3/6/2010 9:54:30 PM GMT

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-06 22:05
    Isn't it the method "rx' which reads a byte from the buffer or waits for one otherwise? But I'm not quite sure what the question is then because this is how these objects are used normally so I must be missing something.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-06 22:09
    How about just using FullDuplexSerial?
  • kwinnkwinn Posts: 8,697
    edited 2010-03-06 22:23
    There is rx which will wait for a byte, rxcheck which checks for a byte and returns the byte or returns -1 if there was no byte, and rxtime which waits for a specified time to receive a byte and returns the byte or -1 if it was not received in the specified time.

    If the packet is sent sequentially with little or no delay between bytes and does not always have a specific last byte such as <cr> I would use rxtime with a suitable delay time.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-03-07 00:26
    Yes, I came across this problem with xmodem file transfers. One simple answer is to use rxcheck as kwinn suggests
    PUB rxcheck : rxbyte
    
    '' Check if byte received (never waits)
    '' returns -1 if no byte received, $00..$FF if byte
    
      rxbyte--
      if rx_tail <> rx_head
        rxbyte := rx_buffer[noparse][[/noparse]rx_tail]
        rx_tail := (rx_tail + 1) & bufmsk
    
    



    And like it says, if there is no byte available you get -1, and if there is then rxbyte contains the byte.

    (as an aside, I needed another routine which would check if any bytes are available but not return the byte at that time. That is quite a simple routine, just a matter of seeing if rx_tail is equal to rx_head)

    There are buffers in the serial code so data can be coming in and you can be reading it out asynchronously.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-07 04:24
    Just as a side note I never use the rx or rxtime method but prefer the rxcheck method for various reasons, one is that I can do other things while waiting for input.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
Sign In or Register to comment.