I’m not sure what to call this thread, but this is good enough. I have been working on a project for most of the summer off and on to provide an alternate method of communicating with the Cortex. I do intend to document the project and post the sample code as soon as I get it robust enough. The project uses XBee parts and the Cortex Serial port.
I got a rudimentary communications working both String based and Binary Based Thanks to a lot of help from James Pearman. I recently upgraded to Robot C 3.51 while supporting a BEST tournament, and afterward found my code no longer works. As so much time > 3weeks had passed since I had it working I quickly came to believe the upgrade was part of the culprit. After downgrading my laptop to 3.08 and the master firmware to 3.21 with a little fiddling I got the code to work again. I am very frustrated with the need for wait statements in Robot C to make an assignment ‘stick’ but more on that when I can build a simple example. Right now it appears some fundamental things have changed with the way Robot C presents the serial port. After ensuring my code was working well under 3.08 i.e. I was transmitting packets of data in both directions 1/sec with no bad packets being received, I copied the code to a PC with Robot C 3.54 ( Since I noticed the problem in 3.51 I went ahead and upgraded to 3.54 out this weekend) and I found the code did not work. I get neither transmission or reception on the Cortex. it acts like its transmitting (I can see the LEDs on my XBee board light up) but I get no (intelligible) data in or out of the Cortex. But when I re-load the 3,21 firmware and the Code on the Cortex (and handset) it works again.
I did notice a compiler warning which might explain the issues with the Rx on the Cortex, but doesn’t seem immediately to point to the problems on the Tx side.
The Errors are below, and I’ll post my code please excuse the roughness this is not ready for prime time, but is the basis for which I’m heading the project example to be.
From the debugger:
File “stringOrBinary.c” compiled on Nov 04 2012 14:41:39
Warning:Truncation of constant value ‘-1’ to ‘unsigned char’ variable range
Warning:Meaningless comparision between ‘unsigned’ value and ‘negative constant’ [L]
The lines of relevant code are here:
task serialPortAscii () {
char cProcessing[INPUT_STRING_SIZE]; // create input buffer
char incomingChar = -1; // Rx data flag
int nCounter = 0; // How Many Chars Rx
bool receiving = false; // keep track of Rx loop vs idle loop
//Clear out existing array data
memset(cProcessing, 0, sizeof(cProcessing));
// need to start infinite loop
while (true) {
// poll for input
incomingChar = getChar(uartTwo);
//
if ( (incomingChar != -1) && (nCounter < INPUT_STRING_SIZE) ) {
// we have a valid data item
It appears to me that getChar now returns an unsigned char vs. a char as it did before. I need to do more digging but would appreciate help in where to look and how to code alternatives.
The Full code for the Cortex and Arduino are posted in zip files below, Be warned this is a work in progress and exposes why I don’t write S/W for a living. And I couldn’t have done the cool stuff without help from Mr Pearman who provided the excellent example of Unions.
The Arduino I use is a Mega 2560 which has multiple H/W UARTs, The serial Comms currently are facilitated by XBee H/W and I spent a lot of time ensuring the XBees work as a simple wireless point to point serial interface. I know they can do a lot more, but for now until I get the robot code working well I am using them in the simplest mode. They do not seem to be the problem, and if you wanted to reproduce my efforts you should be able to hook the serial port of the Cortex to the Arduino directly wore to wire as they are supposedly both 5v tolerant. Indeed I did this several times during the summer to rule out the XBee from some of the issues I found.
In Summary I would like to get the serial port I/F to the Cortex working again in 3.5x like it did in 3.08 or at least understand what I need to change in my code so I can keep this project going in 3.5x and beyond.
Cheers Kb
[ATTACH]6889[/ATTACH]
[ATTACH]6890[/ATTACH]
AdditionalBinaryTesting.zip (3.59 KB)
BinaryWirelessExtendedTesting.zip (4.56 KB)