Changeset cf8cc36 in mainline for uspace/app/test_serial/test_serial.c


Ignore:
Timestamp:
2010-05-14T13:45:28Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c47e1a8
Parents:
04c7003f
Message:

get/set parameters of the serial communication (baud rate, parity, number of stop bits, word size)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/test_serial/test_serial.c

    r04c7003f rcf8cc36  
    9292        }
    9393       
    94         res = ipc_call_sync_1_0(phone, SERIAL_SET_BAUD_RATE, 1200);
     94        unsigned int old_baud, old_par, old_stop, old_word_size;
     95       
     96        res = ipc_call_sync_0_4(phone, SERIAL_GET_COM_PROPS, &old_baud, &old_par, &old_word_size, &old_stop);   
    9597        if (EOK != res) {
    96                 printf(NAME ": failed to set baud rate, errno = %d.\n", -res);
     98                printf(NAME ": failed to get old communication parameters, errno = %d.\n", -res);
    9799                devman_hangup_phone(DEVMAN_CLIENT);
    98100                ipc_hangup(phone);
    99101                free(buf);
    100                 return 4;               
     102                return 4;
    101103        }
     104       
     105        res = ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, 1200, SERIAL_NO_PARITY, 8, 1);     
     106        if (EOK != res) {
     107                printf(NAME ": failed to set communication parameters, errno = %d.\n", -res);
     108                devman_hangup_phone(DEVMAN_CLIENT);
     109                ipc_hangup(phone);
     110                free(buf);
     111                return 4;
     112        }
     113       
    102114       
    103115        int total = 0;
     
    107119                if (0 > read) {
    108120                        printf(NAME ": failed read from device, errno = %d.\n", -read);
     121                        ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud, old_par, old_word_size, old_stop);     
    109122                        ipc_hangup(phone);
    110123                        devman_hangup_phone(DEVMAN_CLIENT);
     
    126139        write_dev(phone, the_end, str_size(the_end));
    127140       
     141        // restore original communication settings
     142        ipc_call_sync_4_0(phone, SERIAL_SET_COM_PROPS, old_baud, old_par, old_word_size, old_stop);     
    128143        devman_hangup_phone(DEVMAN_CLIENT);
    129144        ipc_hangup(phone);
Note: See TracChangeset for help on using the changeset viewer.