23 lines
779 B
C
23 lines
779 B
C
|
|
#ifndef _BY_SERIAL_H__
|
||
|
|
#define _BY_SERIAL_H__
|
||
|
|
|
||
|
|
#define BY_SERIAL_DEV_STATUS_STDBY 0x00
|
||
|
|
#define BY_SERIAL_DEV_STATUS_ERROR 0xFF
|
||
|
|
#define BY_SERIAL_DEV_STATUS_OPEND 0x01
|
||
|
|
|
||
|
|
typedef struct by_serial_t {
|
||
|
|
int fd;
|
||
|
|
char dev_name_str[40];
|
||
|
|
int dev_name_len;
|
||
|
|
int dev_status;
|
||
|
|
} by_serial_t;
|
||
|
|
|
||
|
|
extern int by_serial_init(by_serial_t *serial_port, const char *dev_name);
|
||
|
|
extern int by_serial_set_baudrate(by_serial_t *serial_port, int baudrate);
|
||
|
|
extern int by_serial_set_parity(by_serial_t *serial_port, int databits, int stopbits, char parity);
|
||
|
|
extern int by_serial_write(by_serial_t *serial_port, const char *buff, const int len);
|
||
|
|
extern int by_serial_read(by_serial_t *serial_port, char *buff, const int len);
|
||
|
|
extern int by_serial_get_used_buffer_len(by_serial_t *serial_port);
|
||
|
|
|
||
|
|
#endif
|