Shop OBEX P1 Docs P2 Docs Learn Events
Difference between FullDuplexSerial and JDCogSerial — Parallax Forums

Difference between FullDuplexSerial and JDCogSerial

fmaurerfmaurer Posts: 4
edited 2011-05-13 17:17 in Propeller 1
Hey everyone,

Is there a difference in the rxcheck function of JDCogSerial and FullDuplexSerial?

I need more performance in communicating with my propeller over USB and read that JDCogSerial could do up to 345600 Baud. Since my code only needs to use rxcheck and JDCogSerial implements it, I thought I could simply comment out FDSerial and replace it with JDCogSerial:
'Comm : "Extended_FDSerial"
  Comm : "JDCogSerial"

Here is FDSerials implementation:
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[rx_tail]
    rx_tail := (rx_tail + 1) & $F

...and this is JDCogSerial's:
PUB rxcheck : rxbyte
{ Check if byte received (never waits)
  returns < 0 if no byte received, $00..$FF if byte }
  if (rxbyte := rx1_buf) => 0
    rx1_buf := -1

However, the prop works fine when using FDSerial but not JDCog. I'm stumped, any ideas? (Note that when I switch between the two, I'm careful to pass the correct amount of arguments eg. FDSerial.Start takes 4 while JD.Start takes 3).

I'm using an FTDI chip to send serial over to the propeller, where the first byte tells the propeller how many bytes to fill the first buffer, then it switches buffers and fills the second one. It continues to switch the pointer like this while a modified DMXout cog converts the filled buffer into DMX signals.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-12 22:00
    JDCogSerial keeps its serial buffer in the cog's memory while FullDuplexSerial keeps its buffers in the hub memory. That's why the rxcheck routines work differently. Are you just looking for some kind of serial driver that works fast enough for you? How about using this 4 port serial driver, but just using 1 port? In that case, it claims speeds > 750KBps.
  • fmaurerfmaurer Posts: 4
    edited 2011-05-12 22:30
    Whoa that would be fast, I haven't been able to exceed 57600 baud haha! But I'm still getting the same problem (FDSerial works but not any other driver). I'm thinking it has to do with the implementation of the two. Does it matter if it's cog or hub memory since I'm just reading the last received byte with rxcheck? This is what I have:
    OBJ
    
         'Comm : "Extended_FDSerial"
         Comm : "pcFullDuplexSerial4FC"
    
    PUB Main
    
         'Comm.start(31,30, 0, 57600)
         'AddPort(port,rxpin,txpin,ctspin,rtspin,rtsthreshold,mode,baudrate)
         Comm.AddPort(0,31,30,-1,-1,0,0,57600)
         Comm.Start
    
    repeat                    
         
         recByte := Comm.RxCheck(0)
         if(recByte <> -1)
              '... save into buffer etc. code
    


    It seems so straightforward. I'm thinking it has to do with the way rxcheck is working where it doesn't have access to another cog's memory with this new driver?

    Here's the complete archive:

    USBComm7-bst-archive-110512-222720.zip
  • william chanwilliam chan Posts: 1,326
    edited 2011-05-13 01:04
    Why can't JDCogSerial support mode 3 (Inverted Tx and RX)?
    I thought it just involves putting a slash in front of some assignment to invert the logic.

    I am using FullDuplexSerial_RR04 running at 40Mhz but for some reason I can only achieve around 57600 baud.
  • kuronekokuroneko Posts: 3,623
    edited 2011-05-13 01:35
    fmaurer wrote: »
    However, the prop works fine when using FDSerial but not JDCog. I'm stumped, any ideas?
    Note that FDSerial takes pin numbers as arguments while JDCogSerial takes masks (|< pin) instead. Could that be your problem?

    This works for me:
    CON
      _clkmode = XTAL1|PLL16X
      _xinfreq = 5_000_000
    
    OBJ
      serial: "JDCogSerial"
    
    PUB null | c
    
      serial.start([COLOR="red"]|<[/COLOR] 31, [COLOR="red"]|<[/COLOR] 30, 115200)           ' use pin [COLOR="red"]mask[/COLOR] instead of pin number
      waitcnt(clkfreq*3 + cnt)
    
      repeat
        repeat while (c := serial.rxcheck) < 0
        serial.tx(c)
        
    DAT
    
  • fmaurerfmaurer Posts: 4
    edited 2011-05-13 14:47
    Thanks for the reply, kuroneko. This sounds very probable; I'll check as soon as I get home!

    Other question: I was talking to a guy at work and he told me that I need to check for parity after I receive a byte. I thought this was handled by the FTDI chip. Is what he's saying that after I do rxcheck I need to check for the parity bit as well? Is there a function in FDSerial for this? This would imply I also need to check framing too...so confused now :frown:
  • kuronekokuroneko Posts: 3,623
    edited 2011-05-13 17:17
    fmaurer wrote: »
    I was talking to a guy at work and he told me that I need to check for parity after I receive a byte.
    AFAIK none of the drivers involved here transmits parity (unless you send only 7 bits and (mis)use the 8th bit for parity). So what would be the point of checking parity? Against what?
Sign In or Register to comment.