Beginners: please read this post and this post before posting to the forum.
0 Members and 1 Guest are viewing this topic.
DWORD BytesLidos = 0; int count1=0; int count2=100; uint8_t c[LEN_BUFFER]; while(ReadFile( hCom, c, LEN_BUFFER, &BytesLidos, NULL )){ cout <<"data1: " <<(unsigned short)c[0]<<"\n"; cout <<"data2: "<< (unsigned short)c[1]<<"\n"; DWORD BytesEscritos = 0; int send[2]; send[0] = ++count1; send[1] = ++count2; WriteFile( hCom, send,2, &BytesEscritos, NULL ); }
uint8_t data[2]; data[0] = GET_DATA_USB; data[1] = GET_DATA_USB; uartSendBuffer(UART1, data, 2);
in AVRStudio I tryed to read the data from the serial port and send back them to read in the console in the programm above. Unfortunately I can only get the first byte stored, the second byte I can't, my question is how to receive an array of bytes sent by port com.
char command[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};//this function stores uart data into an array//a 'r' character signals the end of a commandvoid get_wireless_command(void) { int data; uint8_t count=0; data = ZigBeeGetByte();//read from your UART if(data!=-1)//check for wireless command { while(data!='r')//if command is not complete { if(data!=-1)//if data is available { command[count]=data; count++; } data = ZigBeeGetByte(); } //store the r, since it already left the loop command[count]=data; process_command();//data recieved, now update state } }