因为很喜欢边用边学系列的书,就叫这个名字了。可以它们没出C++ 的书呢。
1、在C++中,想要定义结构体是不能把结构体定义在类定义中的(我很奇怪union就可以),通用的做法是,先定义一个结构体,然后在类中定义一个结构体变量:^)
just like:
-
typedef struct epc
-
{
-
unsigned char header;
-
unsigned char type;
-
unsigned char command;
-
unsigned char str[5];
-
unsigned char epc[25];
-
unsigned char crc[2];
-
unsigned char checksum;
-
unsigned char end;
-
}Epc;
-
-
class UhfRfidReader
-
{
-
public:
-
UhfRfidReader();
-
~UhfRfidReader();
-
void uhfReaderConnect();//读接口
-
unsigned char* uhfGetVersion();
-
-
private:
-
typedef
-
enum
-
{
-
SERIAL_8N1 = 0,
-
SERIAL_7E1 = 1,
-
SERIAL_7O1 = 2,
-
SERIAL_7S1 = 3
-
}serial_format;
-
-
-
-
-
-
fd_set set_input;
-
int fd;
-
-
struct timeval timeout;
-
int ret_select;
-
int bytes;
-
int write_num;
-
int read_num;
-
const char * serial_port[];
-
unsigned char buff[];
-
// unsigned char epcbuf24[25] = {"\0"};
-
unsigned char epcbuf24[];
-
unsigned char* buffer_read();//字串处理函数
-
int serial_open(int port);
-
void serial_format_set(int fd, serial_format format);
-
void serial_speed_set(int fd, int baudrate);
-
void serial_etc_config(int fd);
-
void serial_config(int fd, int baudrate, serial_format format);
-
Epc* itoa16(unsigned char* buff);
-
};
2.字符串C模式char*不能直接给C++的string给值,可以给它后面加.c_str()。
举个栗子:
-
ROS_INFO("I heard: [%s]", msg->data.c_str());
阅读(890) | 评论(0) | 转发(0) |