Help, we need a program that drives our robot. The sample programs won't compile because the JoystickDriver.c file is not compilable due to errors. Here are the errors:**Error**:'*' Indirection levels mismatch. Call to 'cCmdMessageRead'. Parameter: 'ubyte * pData' is '(ubyte) tempBuffer)' of type 'ubyte'.*Warning*:Invalid '=' operation for types 'bool' and 'sbyte'*Warning*:Invalid '=' operation for types 'bool' and 'sbyte'**Error**:Procedure call Parameters don't match declaration for 'strcat(char * pToBuffer, char * pFromBuffer)'

Thanks for your help!FYI: We have RobotC for NXT 3.54

Tue Dec 04, 2012 4:57 pm

JohnWatson

Site Admin

Joined: Thu May 24, 2012 12:15 pmPosts: 663

Re: JoystickDriver.c doesn't Compile.

Would you be able to post the entire code using the [code][/code] tags? This way, we will be able to take a deeper look at it and hopefully debug what exactly is going wrong with it. Thank you in advance!

Within JoystickDriver.c we are getting the errors listed above. Neither file has been modified from its original form. This problem started when we upgraded to RobotC 3.54 from 2.26. Here is the code for JoystickDriver.c

Code:

//////////////////////////////////////////////////////////////////////////////////////////////////////////// HiTechnic Servo/Motor Controller Device Driver - UPDATED 1/08/2009////// With the TETRIX system, the PC Controller Station sends messages over Bluetooth to the NXT containing// current settings of a PC joystick. The joystick settings arrive using the standard NXT BLuetooth// "message mailbox" facility.//// This is a short ROBOTC program to extract the joystick data from a mailbox message and format it// into data structure that can be easily acccessed by end user programs.//// The driver resides in a separate file that can be simply added to any user program with a// "#include" preprocessor directive. End users should not have to modify this program and can use// it as is.//////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////// Joystick Information Structure////// Structure containing info from Joystick.//// "short" variables are used to prevent conversion errors. For example, negating a byte variable with// value -128 results in -128 because -128 does not fit in a byte!//////////////////////////////////////////////////////////////////////////////////////////////////////////

const TMailboxIDs kJoystickQueueID = mailbox1;TJoystick joystickCopy; // Internal buffer to hold the last received message from the PC. Do not use

long ntotalMessageCount = 0;

//////////////////////////////////////////////////////////////////////////////////////////////////////////// "Macro" to get a non-volatile copy of the last joystick settings so//////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////// Receive Messages Task//// Dedicated task that continuously polls for a Bluetooth message from the PC containing the joystick// values. Operaton of this task is nearly transparent to the end user as the earlier "#pragma autoStartTasks"// statement above will cause it to start running as soon as the user program is started.//// The task is very simple. It's an endless loop that continuously looks for a Bluetooth mailbox// message from the PC. When one is found, it reformats and copies the contents into the internal// "joystickCopy" buffer.//////////////////////////////////////////////////////////////////////////////////////////////////////////

int cyclesWithoutUpdate = 0; while (true) { // Check to see if a message is available. bMsgFound = false; while (true) { // // There may be more than one message in the queue. We want to get to the last received // message and discard the earlier "stale" messages. This loop simply discards all but // the last message. // int nSizeOfMessage;

// // No more messages available and at least one message found. This is not essential but // useful to ensure that we're working with the latest message. We simply discard earlier // messages. This is useful because there could be many messages queued and we don't // want to work with stale data. // break; } if (nSizeOfMessage > sizeof(tempBuffer)) nSizeOfMessage = sizeof(tempBuffer); nBTCmdRdErrorStatus = cCmdMessageRead((ubyte)tempBuffer, nSizeOfMessage, kJoystickQueueID); nBTCmdRdErrorStatus = nBTCmdRdErrorStatus; //Get rid of info message // // Repeat loop until there are no more messages in the queue. We only want to process the // last message in the queue. // bMsgFound = true; }

cyclesWithoutUpdate = 0; // Once we've reached here, a valid message is available

#if defined(TETRIX)/////////////////////////////////////////////////////////////////////////////////////////////// displayDiagnostics//// THis task will display diagnostic information about a TETRIX robot on the NXT LCD.//// If you want to use the LCD for your own debugging use, call the function// "disableDiagnosticsDisplay()/////////////////////////////////////////////////////////////////////////////////////////////

bool bDisplayDiagnostics = true; // Set to false in user program to disable diagnostic display

/////////////////////////////////////////////////////////////////////////////////////////////// getUserControlProgram//// This function returns the name of the TETRIX User Control program. It reads the file// "FTCConfig.txt" and builds the name of the file from the contents.//// Note that the filename includes the ".rxe" (robot executable file) file extension./////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////// waitForStart//// Wait for the start of either the autonomous or tele-op phase. User program is running on the NXT// but the phase has not yet started. The FMS (Field Management System) is continually (every 50 msec)// sending information to the NXT. This program loops getting the latest value of joystick settings.// When it finds that the FMS has started the phase, it immediately returns.///////////////////////////////////////////////////////////////////////////////////////////////////////

Last edited by NBCRobotics on Wed Dec 05, 2012 4:36 pm, edited 1 time in total.

Tue Dec 04, 2012 5:15 pm

NBCRobotics

Rookie

Joined: Tue Dec 04, 2012 4:51 pmPosts: 4

Re: JoystickDriver.c doesn't Compile.

Our problem seems to lie in passing the Joystick stack to the NXT and is specific to RobotC v3.54.

When using RobotC v2.26, we are able to connect via bluetooth, download programs, and control motors with the game controller wirelessly.

When using RobotC v3.54, we are able to connect via bluetooth and download programs, however, JoystickDriver.c creates errors and won't compile. If we comment out the 2 offending lines of code, everything compiles and downloads. We can then run the program from the Joystick Control - FTC menu, however at that point things break down. The joystick menu on screen properly displays the current state of all buttons, but I don't think that information is being passed to the NXT (either because of the commented-out lines of JoystickDriver.c or as part of the root cause of the problem).

I have tested various programs, attempted to display the values being parsed by JoystickDriver.c to the NXT screen, and placed code in both the initializerobot and main tasks to further refine the source of the problem. As far as I can tell, the tempbuffer array is empty and no actual values are being passed to the joystick object. This leads to issues with WaitForStart() because it references Joystick.StopPgm, and setting a motor = Joystick.joy1_y1 leaves the motor set to 0.

At this point we are able to get basic functionality using RobotC 2.26, but it doesn't have support to use the IR sensors for this year's challenge.

Please help with any insight you may have as to workarounds or solutions.

Thank you,The Greyhounds

Wed Dec 05, 2012 4:18 pm

JohnWatson

Site Admin

Joined: Thu May 24, 2012 12:15 pmPosts: 663

Re: JoystickDriver.c doesn't Compile.

I've done a side-by-side comparison of the JoystickDriver.c code you've posted and the current version, and there are a few major differences between the two: I'm assuming the JoystickDriver.c file that you have is from the previous 2.0 version that was on the computer and for some reason didn't get updated.

I would suggest doing a clean uninstall/reinstall of ROBOTC (making sure to clean out the ROBOTC directory to ensure that new files are loaded with the install). Alternatively, I can post a link to just the newer JoystickDriver.c file, but I would still be concerned about the possible age of the other files (such as ROBOTCIntrinsics.c) that are used extensively in ROBOTC.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum