使用命令行参数
This commit is contained in:
@@ -34,7 +34,7 @@ public:
|
||||
Uart();
|
||||
void sendTarget(float x, float y ,float z);
|
||||
|
||||
char receive();
|
||||
uint8_t receive();
|
||||
void receive_data();
|
||||
};
|
||||
|
||||
|
||||
7
main.cpp
7
main.cpp
@@ -93,9 +93,10 @@ void uartReceive(Uart* uart){
|
||||
char buffer[100];
|
||||
int cnt=0;
|
||||
while(true){
|
||||
char data;
|
||||
while((data=uart->receive()) != '\n'){
|
||||
buffer[cnt++] = data;
|
||||
unsigned int data;
|
||||
while(1){
|
||||
cout << (data=uart->receive()) << endl;
|
||||
// buffer[cnt++] = data;
|
||||
}buffer[cnt] = 0;
|
||||
if(cnt==1 && buffer[0]=='e'){
|
||||
state = ENERGY_STATE;
|
||||
|
||||
@@ -153,8 +153,8 @@ void Uart::sendTarget(float x, float y, float z) {
|
||||
// 's' + (x) ( 8bit + 8bit ) + (y) ( 8bit + 8bit ) + (z) ( 8bit + 8bit ) + 'e'
|
||||
|
||||
|
||||
char Uart::receive() {
|
||||
char data;
|
||||
uint8_t Uart::receive() {
|
||||
uint8_t data;
|
||||
while(read(fd, &data, 1) < 1);
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user