[NXC][API][Bug][Compile Error] SendRemoteString

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

[NXC][API][Bug][Compile Error] SendRemoteString

Post by muntoo »

On the October 16, 2010 test release of BricxCC, I get a compile error with the following code:

Code: Select all

/*
void SendSensorPSP(conn, queue, port, i2cAddr)
Reads information about the PSP sensor of the specified port and I2C Address,
and sends it over the specified BlueTooth connection to the specified queue
*/
void SendSensorPSP(byte conn, byte queue, const byte port, byte i2cAddr)
{
   byte buffer[];
   string szBuffer = "";
   string szSend = "";
   
   I2CReadEx(port, i2cAddr, 0x00, 24, buffer);
   
   szBuffer = FlattenVar(buffer);
   strcat(szSend, szBuffer);
//   szSend = StrCat(szSend, szBuffer);
   
   I2CReadEx(port, i2cAddr, 0x40, 8, buffer);
   
   szBuffer = FlattenVar(buffer);
   strcat(szSend, szBuffer);
//   szSend = StrCat(szSend, szBuffer);
   
   while(SendRemoteString(conn, queue, szSend) == STAT_COMM_PENDING);
}
This line:

Code: Select all

while(SendRemoteString(conn, queue, szSend) == STAT_COMM_PENDING);
This didn't happen in the stable release...
Last edited by muntoo on 05 Mar 2011, 06:21, edited 2 times in total.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXC Compile Error SendRemoteString

Post by afanofosc »

muntoo wrote:On the October 16, 2010 test release of BricxCC, I get a compile error with the following code:

Code: Select all

while(SendRemoteString(conn, queue, szSend) == STAT_COMM_PENDING);
Yes, I broke that accidentally. I have fixed the problem and will upload a new test release later today.

It was broken as a result of the substantial changes I made to the API header files in order to unify sending direct and system commands and bool, number, and string values from one NXT to another over Bluetooth and RS485 connections.

In the latest test release all the Remote* and SendRemote* API functions work with both Bluetooth and RS485 connections. You can specify the connection number (now) as a variable or a constant. There are new predefined connection number constants: CONN_BT0, CONN_BT1, CONN_BT2, CONN_BT3, and CONN_RS4. To send via the hi-speed RS485 port you use CONN_RS4 which is equal to the number 4. If you target the standard firmware you do not get the RS485 support.

The test release includes the following new Remote* API functions:

Code: Select all

inline bool RemoteConnectionIdle(byte conn);
inline char RemoteConnectionWrite(byte conn, byte buffer[]);

inline char RemoteGetBatteryLevel(byte conn);
inline char RemoteLowspeedGetStatus(byte conn);
inline char RemoteGetCurrentProgramName(byte conn);
inline char RemoteGetContactCount(byte conn);
inline char RemoteGetConnectionCount(byte conn);
inline char RemoteGetOutputState(byte conn, byte port);
inline char RemoteGetInputValues(byte conn, byte port);
inline char RemoteLowspeedRead(byte conn, byte port);
inline char RemoteResetTachoCount(byte conn, byte port);
inline char RemoteGetProperty(byte conn, byte property);
inline char RemoteDatalogRead(byte conn, bool remove);
inline char RemoteBTGetContactName(byte conn, byte idx);
inline char RemoteBTGetConnectionName(byte conn, byte idx);
inline char RemoteDatalogSetTimes(byte conn, long synctime);
inline char RemoteSetProperty(byte conn, byte prop, variant value);
inline char RemoteLowspeedWrite(byte conn, byte port, byte txlen, byte rxlen, byte data[]);

inline char RemoteOpenRead(byte conn, string filename);
inline char RemoteOpenAppendData(byte conn, string filename);
inline char RemoteDeleteFile(byte conn, string filename);
inline char RemoteFindFirstFile(byte conn, string mask);
inline char RemoteGetFirmwareVersion(byte conn);
inline char RemoteGetBluetoothAddress(byte conn);
inline char RemoteGetDeviceInfo(byte conn);
inline char RemoteDeleteUserFlash(byte conn);
inline char RemoteBluetoothFactoryReset(byte conn);
inline char RemoteOpenWrite(byte conn, string filename, long size);
inline char RemoteOpenWriteLinear(byte conn, string filename, long size);
inline char RemoteOpenWriteData(byte conn, string filename, long size);
inline char RemoteCloseFile(byte conn, byte handle);
inline char RemoteFindNextFile(byte conn, byte handle);
inline char RemotePollCommandLength(byte conn, byte bufnum);
inline char RemoteWrite(byte conn, byte handle, byte data[]);
inline char RemoteRead(byte conn, byte handle, byte numbytes);
inline char RemoteIOMapRead(byte conn, long id, int offset, int numbytes);
inline char RemoteIOMapWriteValue(byte conn, long id, int offset, variant value);
inline char RemoteIOMapWriteBytes(byte conn, long id, int offset, byte data[]);
inline char RemoteSetBrickName(byte conn, string name);
inline char RemoteRenameFile(byte conn, string oldname, string newname);
inline char RemotePollCommand(byte conn, byte bufnum, byte len);
The signature and behavior of several of these functions may change before the next official release since right now they send the command and do nothing about reading the response packet. It may be worth the extra effort to add to these functions the receiving side of the equation (so long as you have the enhanced firmware on your NXT). If I do that then the functions that process the response will probably return a structure containing the response data.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
linusa
Posts: 228
Joined: 16 Oct 2010, 11:44
Location: Aachen, Germany
Contact:

Re: NXC Compile Error SendRemoteString

Post by linusa »

afanofosc wrote: Yes, I broke that accidentally. I have fixed the problem and will upload a new test release later today.
John, would it be an easy task for you to introduce some sort of "regression tests"? You could have some sort "compile all examples" script, and the more syntactically correct NXC programs you have (maybe the ones from your book), the better.

Ideally, you could then run these compilations as test ("quality gate") before releasing a new version. Just an idea... Depending on your scripting skills and directory structure, it shouldn't take long to create a program in whatever language to create a batch-file that tries to compile all NXC programs.

Sorry for posting this, you see, I'm still reading Code Complete and trying to spread the knowledge out into the world :-)
RWTH - Mindstorms NXT Toolbox for MATLAB
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXC Compile Error SendRemoteString

Post by afanofosc »

Yes, I need to improve my regression tests. In this case, though, the test would have had to check whether you could pass a variable containing the connection number vs a constant (i.e., const byte vs byte or const byte &).

Anyone who wants to help me setup a great system for regression testing is welcome to do so. :-)

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXC Compile Error SendRemoteString

Post by mightor »

Getting something to compile is one thing, making sure it actually behaves the way it's supposed to is quite another :)

- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: NXC Compile Error SendRemoteString

Post by muntoo »

afanofosc wrote:Yes, I need to improve my regression tests. In this case, though, the test would have had to check whether you could pass a variable containing the connection number vs a constant (i.e., const byte vs byte or const byte &).

Anyone who wants to help me setup a great system for regression testing is welcome to do so. :-)

John Hansen
Sorry if this doesn't make any sense, but why don't you just use WinMerge? (I haven't downloaded the program, so I don't know what it does.)
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXC Compile Error SendRemoteString

Post by afanofosc »

I use winmerge all the time but it didn't help me avoid this error.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests