Announcement

Collapse
No announcement yet.

Having problems setting the baud rate with the PES-2407

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Having problems setting the baud rate with the PES-2407


    Hello!

    I've been using the PES-2407 (RS485 Smart expansion board) and I've been trying to set the baud rate but I keep getting an error saying the argument I've entered is invalid. The code I currently have is this:
    Code:
    spc_reset();
    spc_sync_baud(2400);
    spc_request_dev(MOUNT_SID, "set uart 2400N81T");
    But the error I get says:
    php0> PHP error: invalid argument in file lib/sd_spc.php on line 37
    And it shows that line 37 in this function is what is causing the error:
    Code:
    33    function spc_sync_baud($baud = 115200, $t1 = 1, $t2 = 100)
    34    {
    35        $pid = sd_spc_pid_open_nodie("/mmap/spc0", "spc_sync_baud");
    36
    37        pid_ioctl($pid, "set baud $baud");
    38        pid_ioctl($pid, "sync baud $t1 $t2");
    39
    40        while(pid_ioctl($pid, "get state"))
    41        usleep(1);
    42
    43        pid_close($pid);
    44    }
    Previously I was using the normal expansion board for RS485 communication and I used
    Code:
    pid_ioctl($pid, "set baud 2400");
    command and I never had problems with it. Any help on what I'm doing wrong would be greatly appreciated. Thank you!

  • #2
    Hello,
    There are two different baudrate:
    - baudrate for communication between PHPoC and PES-2407. This is set via spc_sync_baud() function
    - baudrate for RS-422/485 communication on PES-2407. This is set via spc_request_dev() function

    The available baudrate for communication between PHPoC and PES-2407 are: 115200, 230400, 460800, and 921600. Therefore in your code spc_sync_baud(2400), 2400 is an invalid value

    For baudrate for RS-422/485 communication on PES-2407, the baudrate is any value in between 1200 ~ 115200

    Comment


    • #3
      Khanh,

      That makes more sense and explains why later the baud rate is set to 2400 using uart. That fixed my problem, thank you!

      Comment


      • Khanh
        Khanh commented
        Editing a comment
        You're welcome!
    Working...
    X