Changeset f619943a in mainline


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

set baud rate from test_serial application; fixed a bug

Location:
uspace
Files:
3 edited

Legend:

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

    rf4ef3c2 rf619943a  
    4646#include <device/char.h>
    4747#include <string.h>
     48#include <ipc/serial_ctl.h>
    4849
    4950#define NAME            "test serial"
     
    9192        }
    9293       
     94        res = ipc_call_sync_1_0(phone, SERIAL_SET_BAUD_RATE, 1200);
     95        if (EOK != res) {
     96                printf(NAME ": failed to set baud rate, errno = %d.\n", -res);
     97                devman_hangup_phone(DEVMAN_CLIENT);
     98                ipc_hangup(phone);
     99                free(buf);
     100                return 4;               
     101        }
     102       
    93103        int total = 0;
    94104        int read = 0;
     
    100110                        devman_hangup_phone(DEVMAN_CLIENT);
    101111                        free(buf);
    102                         return 4;
     112                        return 5;
    103113                }               
    104114                total += read;
  • uspace/lib/libc/include/ipc/dev_iface.h

    rf4ef3c2 rf619943a  
    4545#define DEV_IFACE_IDX(id) ((id) - IPC_FIRST_USER_METHOD)
    4646
    47 #define DEV_IFACE_COUNT DEV_IFACE_MAX
    48 #define DEV_FIRST_CUSTOM_METHOD DEV_IFACE_MAX
     47#define DEV_IFACE_COUNT                                 DEV_IFACE_MAX
     48#define DEV_FIRST_CUSTOM_METHOD_IDX     DEV_IFACE_MAX
     49#define DEV_FIRST_CUSTOM_METHOD                 DEV_IFACE_ID(DEV_FIRST_CUSTOM_METHOD_IDX)
    4950
    5051
  • uspace/srv/drivers/serial/serial.c

    rf4ef3c2 rf619943a  
    119119static int serial_read(device_t *dev, char *buf, size_t count)
    120120{
    121         printf(NAME ": serial_read %s\n", dev->name);
     121        // printf(NAME ": serial_read %s\n", dev->name);
    122122       
    123123        int ret = 0;
     
    342342       
    343343        if (50 > baud_rate || 0 != MAX_BAUD_RATE % baud_rate) {
     344                printf(NAME ": error - somebody tried to set invalid baud rate %d\n", baud_rate);
    344345                return EINVAL;
    345346        }
     
    364365        ioport8_t *port = data->port;
    365366        int ret;
     367       
     368        printf(NAME ": set baud rate %d for the device %s.\n", baud_rate, dev->name);
    366369       
    367370        fibril_mutex_lock(&data->mutex);       
     
    380383       
    381384        serial_port_interrupts_disable(port);     // Disable all interrupts
    382         serial_port_set_baud_rate(port, 1200);
     385        serial_port_set_baud_rate(port, 38400);
    383386        pio_write_8(port + 3, 0x07);    // 8 bits, no parity, two stop bits
    384387        pio_write_8(port + 2, 0xC7);    // Enable FIFO, clear them, with 14-byte threshold
     
    398401                if (cont = serial_received(port)) {
    399402                        uint8_t val = serial_read_8(port);
    400                         printf(NAME ": character %c read from %s.\n", val, dev->name);
    401                        
     403                        // printf(NAME ": character %c read from %s.\n", val, dev->name);                       
    402404                       
    403405                        if (data->client_connected) {
     
    408410                                }
    409411                        } else {
    410                                 printf(NAME ": no client is connected to %s, discarding the character which was read.\n", dev->name);
     412                                // printf(NAME ": no client is connected to %s, discarding the character which was read.\n", dev->name);
    411413                        }                       
    412414                }
Note: See TracChangeset for help on using the changeset viewer.