smart-greenhouse/smart_greenhouse_sever/inc/serial.h
2022-02-05 17:20:12 +08:00

42 lines
753 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __SERIAL_H__
#define __SERIAL_H__
struct env{
int id;
float tem;
float hum;
int light;
//int smog;
int x;
int y;
int z;
unsigned char led ;
unsigned char fan;
unsigned char buzz;
};
extern struct env data;
/**
* 打开串口设备
* @param[in] devpath 串口设备路径
* @return 打开的文件描述符
* @retval 0 打开设备失败,原因见errno
*/
int serial_open(char *devpath) ;
void serial_Close(int fd) ;
int serial_Set(int fd, int speed, int flow_ctrl, int databits, int stopbits, int parity) ;
int serial_init(char *devpath) ;
int serial_recv_exact_nbytes(int fd, void *buf, int count);
int serial_send_exact_nbytes(int fd, unsigned char *buf, int count);
int serial_exit(int fd);
#endif