Shop OBEX P1 Docs P2 Docs Learn Events
Half and Full Duplex (RS232) — Parallax Forums

Half and Full Duplex (RS232)

Does anyone know what is the protocol format (Half and Full Duplex (RS232) ) of the C function call, fdserial_rxChar and fdserial_txChar , as well as serial_rxChar and serial_txChar? I use baudrate, 9600 and 8-N-1. But the serial terminal (virtual terminal) like TeraTerm shows very crazy characters with the “Hello, RS232”, message in the tutorial. The receiving side couldn't show any characters. I can use two Propeller chips to talk to each other by using those c functions, but not a standard virtual terminal. Any helps are most welcome. Thanks.

Comments

  • VonSzarvasVonSzarvas Posts: 3,332
    edited 2023-07-12 06:52

    First things to check would be that the tx and rx are wired the right way around, and that the serial port configuration call "fdserial_open" has the correct mode set (the 3rd param I think ?).

    The required mode can vary, depending on what device you are connecting to.

  • Here is some sample code to loop back data from two other pins back to the console.

    #include "simpletools.h"
    #include "fdserial.h"
    
    fdserial *trm;
    terminal *dft;
    int c;
    
    int main()
    {
      simpleterm_close();
    
      trm = fdserial_open(31, 30, 0, 115200);
      dft = fdserial_open(0, 1, 0, 115200);
    
      pause(1000);
      dprint(trm, "Ready\n");
    
      while (1)
      {
        c = fdserial_rxCheck(trm);
        if (c > 0)
          fdserial_txChar(dft, c);
        c = fdserial_rxCheck(dft);
        if (c > 0)
          fdserial_txChar(trm, c);
      }
      fdserial_close(trm);
      fdserial_close(dft);
    }
    

    Mike

  • Thank you very much VonSzarvas and iseries. Here was the test results I had yesterday. By define: fdserial_open(-1, 21, 0, 9600), the input character '1' (0011 0001), then the terminal shows 'g' (0110 0111); input '2' (0011 0010) shows '3' (0011 0011); input '3' shows 'f'; input '4', didn't show anything; input '5', shows 'e' . . . . . .

    By choosing Mode = 1, the same results as Mode = 0.

    Good news are that this morning, following VonSzarvas' idea, I made a brave try: set Mode = 2. Than it works great. I don't know the logic because it doesn't follow the description in the fdserial.h. But I will try fdserial_rxChar to see whether it also work as fdwerial_txChar. I will report back my luck.

    Again, thank both of you very much.

Sign In or Register to comment.