initial commit

This commit is contained in:
bmy
2024-05-17 01:57:18 +08:00
commit 478e698ae9
19 changed files with 3821 additions and 0 deletions

22
by_serial.h Normal file
View File

@@ -0,0 +1,22 @@
#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