AT get function lags main program - 900 HP programmable

I am trying to collect XBee parameters, TP/Temperature for example but when I call the function from Main it appears the rest of main finishes running while the AT command is being processed. This is preventing me from capturing the output of the AT request and using it in the rest of main. I know its something simple but could use some advice as to how to get main to wait for the response before continuing.

Thanks for the help,

I’ve stripped down main to this:

printf("MAIN START
printf("Reading TP value
printf("MAIN END


I get this output

Reading TP value

ATTP: 00 1C

Are you using API mode or AT mode on the radio?

It is in API without escapes mode (1)

I could not figure out how to capture the AT result in MAIN so I had to place code within the command_dump function. I am no C coder so pardon the possibly poor code, but it works.

//Sends Temperature info
if ( strncmp(response->command.str, “TP”, 2) == 0 )
memset(SendBuffer, 0, 100 * sizeof(SendBuffer[0]));
AT Read: %s = %d
", response->command.str, response->value_bytes[1] );
strcat(SendBuffer, “Temperature:”);
sprintf(IntegerString, “%d”, response->value_bytes[1]);
//sprintf(IntegerString, “%02x”, response->value_bytes[1]);
strcat(SendBuffer, IntegerString);
env.payload = SendBuffer;
//printf("AT env.payload: %02x
", env.payload );
env.length = strlen(SendBuffer);
//printf("AT env.length: %i

", env.length );

  //Sends data

I did some searching in the Code Warrior and I am not finding this command you want to use.

Why are you not using the xbee_cmd_request
and xbee_cmd_response commands that exist?

Thanks for the response.

Either I missed something or its not quite that simple - My C is pretty weak. From what I could tell, using the at_interactive sample program, the process flow goes something like this:

process_command( &xdev, buffer) - Buffer = the AT command requested

Which calls
process_command_remote(xbee, cmdstr, NULL);

Which calls
request = xbee_cmd_create( xbee, cmdptr)

Which finally calls
xbee_cmd_create( xbee, command)

Then you have to unwind and interpret the results with command_dump - This is where I captured the result and sent the data to the base station.

I still don’t know how to capture within MAIN to actually use it locally.

Even the sample program sends the AT request then moves on in MAIN, only later printing the result from AT, regardless of what is going on in MAIN - separate thread apparently.

Wrong example. Try using the AT command Local example instead. It has it calling the commands from the Main.c file.

Ah yes, my initial question/example was actually using the AT command local sample app, stripped down. My problem appears to be that the XBee command runs in its own ‘thread’ and main continues on. The AT result is not printed by MAIN but actually the same function, command_dump. I would love an example that actually pulls the AT command back into MAIN as I didn’t solve my problem, I just worked around it by shipping out the data to my base station.