Society of Robots - Robot Forum
Software => Software => Topic started by: Henrique on October 16, 2010, 12:10:07 PM
-
Hi again :-X
how can I send/receive data for the axon??? through the UART
Thanks anyone who can help!
-
Have you read this yet? SoR Microcontroller UART tutorial (http://www.societyofrobots.com/microcontroller_uart.shtml)
Alternatively you can use WebBot's Project Designer and assign the output to the UART for a quick output.
-
hmm, but in case of a connection, for example I need to send some data from the axon to my computer and then send a given computer to the axon. Since this connection is only over when I turn off the axon. Which method do you recommend?
and I need to buy extra hardware for this?
I already do connect to the axon via the usb of my computer.
-
UART is bidirectional. You can use the single USB connection and communicate bidirectionally across it. If you look at WebBotLib's servosCenter() it gives an example of this.
-
Humm alright!
Thanks a lot!
-
These should also help:
http://www.societyofrobots.com/programming_data_logging.shtml (http://www.societyofrobots.com/programming_data_logging.shtml)
http://www.societyofrobots.com/electronics_bluetooth_robot.shtml (http://www.societyofrobots.com/electronics_bluetooth_robot.shtml)
-
enjoying the topic
I'm programming a serial communication by the Windows API, and I have this code sending an array int to the serial port (COM), and I read the response (by the axon) in the console
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 );
}
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.
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.
This is how I put received data into an array:
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 command
void 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
}
}