initial commit
This commit is contained in:
33
hx_serial.h
Normal file
33
hx_serial.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#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;
|
||||
|
||||
/* Open serial device. */
|
||||
extern int by_serial_init(by_serial_t *serial_port, const char *dev_name);
|
||||
|
||||
/* Set baudrate. */
|
||||
extern int by_serial_set_baudrate(by_serial_t *serial_port, int baudrate);
|
||||
|
||||
/* Set databits, stopbits, parity. */
|
||||
extern int by_serial_set_parity(by_serial_t *serial_port, int databits, int stopbits, char parity);
|
||||
|
||||
/* Write buff of specified length, return wrote length. */
|
||||
extern int by_serial_write(by_serial_t *serial_port, const char *buff, const int len);
|
||||
|
||||
/* Read buff of specified length, return read length. */
|
||||
extern int by_serial_read(by_serial_t *serial_port, char *buff, const int len);
|
||||
|
||||
/* Return used serial buffer len. */
|
||||
extern int by_serial_get_used_buffer_len(by_serial_t *serial_port);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user