使用命令行参数

This commit is contained in:
xinyang
2019-04-14 20:06:47 +08:00
parent 1070c5caa7
commit 34ba7df66f
3 changed files with 7 additions and 6 deletions

View File

@@ -34,7 +34,7 @@ public:
Uart();
void sendTarget(float x, float y ,float z);
char receive();
uint8_t receive();
void receive_data();
};

View File

@@ -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;

View File

@@ -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;
}