Bluetooth "extras"

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
mcsummation
Posts: 220
Joined: 23 Jan 2012, 17:07
Location: Round Rock, TX

Bluetooth "extras"

Post by mcsummation »

I have rolled a bunch of the discussions and my own experience about using Bluetooth into a library and placed it here. Feel free to use it. If anyone is running an active multi-threaded application using BT, I would be interested to know if this solves any problems you have been having with SendRemote... Yes, I believe these are thread-safe, but it is hard to generate a test case to really stress it. These do not change the way the BT implementation works, these sit on top of the existing functions. Note that Float and Struct are 2 of the data types supported. Testing the Struct functions was where I discovered that strings don't work right in a struct that gets flattened unless you put a lot of work into it.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Bluetooth "extras"

Post by HaWe »

not bad, really: not bad... :)
1)
A rather heated exchange between John Hanson and an NXC user regarding the “proper” usage of the Mailbox system communicating between one or more Slave NXTs and the Master NXT, ...
I'm really curious: who was that guy?

2) how should the init routine look like to use your library (except #include "BT_JHS_TOOLS_H.nxc" as I called it) ?

3) what part of this stuff http://www.mcsummation.com/Mindstorms/B ... _Stuff.nxc should be included into the master's and which into the slave's program?
Last edited by HaWe on 17 Mar 2012, 18:07, edited 1 time in total.
mcsummation
Posts: 220
Joined: 23 Jan 2012, 17:07
Location: Round Rock, TX

Re: Bluetooth "extras"

Post by mcsummation »

Did the web page translate into something that you can read? Since my German is minimal, I have no idea whether or not it is readable.

The Init routine is not necessary to use the other BT functions. It is mainly to get the Master and Slave going properly.

After including BT_Stuff into your Master or Slave, use my Send/Receive routines in place of the standard ones. They simply provide some "value added" on top of the standard ones.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Bluetooth "extras"

Post by HaWe »

I didn't translate your text - to my experience google translate mixes and muddles up any foreign language text into something completely unintelligible and meaningless stuff. So I just tried to understand the sense of the English text.

I don't know if I understood something wrong or miss something, but I was searching for "init" in your source code but couldn't find anything like this.
But I usually find it hard to understand "foreign" code and to navigate through it.
Or should I write a routine BT_init by my own where I put in some of your BT functions ? (Which?)

Maybe you could give an example of source code how to use it on the master and a slave to do something more or less useless?

That's the code I have now:

Code: Select all

// file: BT_JHS_TOOLS_H.nxc

// This is a collection of Bluetooth things from James Summers (also known as McSummation).

// This will wait for the Bluetooth link to become idle.
// Use - WaitBT(connection_number);
#define WaitBT(Conn) until (RemoteConnectionIdle(Conn)) Yield()

#ifndef JHS_BT
#define JHS_BT
mutex JHS_BT_mutex;
bool bBT_Stop = false;
// Implement a thread-safe counting semaphore.
mutex McSummation;
inline long JHSSemaphoreUp(long &Sem) {Acquire (McSummation); Sem++; Release (McSummation); return Sem;}
inline long JHSSemaphoreDown( long &Sem) {Acquire (McSummation); Sem--; Release (McSummation); return Sem;}
#endif

// To kill the "receive" routines while they are waiting for a message, use JHSStopBT();
// When the "receive" routine returns, the return code will be "1";
//  otherwise, it is the return code from the underlying "receive" routine.
inline bool JHSStopBT() {bBT_Stop = true; return bBT_Stop;}
inline bool JHSIsBtStopping() {return bBT_Stop;}

// These connect/disconnect a Slave which has been paired with this Master over the specified connection.
bool ConnectBT(byte Conn, string SlaveName);
sub DisconnectBT(byte Conn);

// This will send a file from the Master to a Slave NXT.
inline int BTSendFile(byte Conn, string FileName);

// These versions of the Bluetooth mailbox functions are thread-safe.
inline char JHSSendRemoteBool( byte conn, byte queue, bool bval);
inline char JHSReceiveRemoteBool( byte conn, byte queue, bool clear, bool &bval, bool bwait = true);
inline char JHSSendResponseBool( byte conn, byte queue, bool bval);
inline char JHSSendRemoteNumber( byte conn, byte queue, long val);
inline char JHSReceiveRemoteNumber( byte conn, byte queue, bool clear, long &val, bool bwait = true);
inline char JHSSendResponseNumber( byte conn, byte queue, long val);
inline char JHSSendRemoteString( byte conn, byte queue, string val);
inline char JHSReceiveRemoteString( byte conn, byte queue, bool clear, string &val, bool bwait = true);
inline char JHSSendResponseString( byte conn, byte queue, string val);
inline char JHSSendRemoteFloat( byte conn, byte queue, float val);
inline char JHSReceiveRemoteFloat( byte conn, byte queue, bool clear, float &val, bool bwait = true);
inline char JHSSendResponseFloat( byte conn, byte queue, float val);
// These are methods of sending a structure to/from the slave.
#define JHSSendRemoteStruct(__conn, __queue, __struct) { \
    string msg; \
    msg = FlattenVar(__struct); \
    JHSSendRemoteString(__conn, __queue, msg); }
#define JHSReceiveRemoteStruct(__conn, __queue, __struct) \
    string msg; \
    JHSReceiveRemoteString(__conn, __queue, true, msg); \
    UnflattenVar(msg, __struct); \
    NumOut(0,LCD_LINE8,StrLen(msg));
#define JHSSendResponseStruct(__conn, __queue, __struct) \
    string msg; \
    msg = FlattenVar(__struct); \
    JHSSendResponseString(__conn, __queue, msg);

// This is used to send a file over the Bluetooth link.

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline int BTSendFile(byte Conn, string FileName) {
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#ifndef JHS_CEFT
#define JHS_CEFT
            CommExecuteFunctionType JHS_CEFT_args;
#endif
            JHS_CEFT_args.Cmd = INTF_SENDFILE;
            JHS_CEFT_args.Param1 = Conn;
            JHS_CEFT_args.Name = FileName;
            SysCommExecuteFunction(JHS_CEFT_args);
            until (RemoteConnectionIdle(Conn)) Yield();
            return JHS_CEFT_args.Result;
        }

// This links to a Slave NXT.
// It returns true if the link was successful.
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bool ConnectBT(byte Conn, string SlaveName)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
  CommBTConnectionType args;
  args.Name = SlaveName;      // Name of the slave NXT
  args.ConnectionSlot = Conn; // This is the desired connection slot
  args.Action = true;         // Connect to the slave
  if(BluetoothStatus(Conn) != NO_ERR)
  {
    SysCommBTConnection(args); // try to connect.
    for (int i = 0; i < 10000; i++)  // Will try for about 10 seconds before failing.
    {
      if(BluetoothStatus(Conn)==NO_ERR)
        return true;  // Connect has completed.
      Wait(1);
    }
  }
  return false;
}

// This disconnects the Bluetooth link.
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
sub DisconnectBT(byte Conn)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
  CommBTConnectionType args;
  args.ConnectionSlot = Conn; // This is the desired connection slot
  args.Action = 0;            // Disconnect
  if(BluetoothStatus(Conn) == NO_ERR)
  {
    // It is connected, so disconnect it.
    SysCommBTConnection(args);
    for (int i = 0; i < 10000; i++)  // Will try for about 10 seconds.
    {
      if(BluetoothStatus(Conn)!=NO_ERR)
        break;  // Disconnect has completed.
      Wait(1);
    }
  }
}

// BT Bool functions.

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline char JHSSendRemoteBool( byte conn, byte queue, bool bval)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
    char rc;
    until (false)
    {
        Acquire(JHS_BT_mutex);
        if (RemoteConnectionIdle(conn))
            break;
        else
        {
            Release(JHS_BT_mutex);
            Yield();
        }
    }
    rc = SendRemoteBool(conn, queue, bval);
    Release(JHS_BT_mutex);
    return rc;
}


//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline char JHSReceiveRemoteBool( byte conn, byte queue, bool clear, bool &bval, bool bwait = true)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
    queue += (conn << 6);
    if (bwait)
    {
        until (NO_ERR == ReceiveRemoteBool(queue, false, bval))
        {
            Wait(1);
            if (bBT_Stop)
            {
                return 1;
                break;
            }
        }
    }
    if (!bBT_Stop)
        { return ReceiveRemoteBool(queue, clear, bval); }
    else
        { return 1; }
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline char JHSSendResponseBool( byte conn, byte queue, bool bval)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
    // This doesn't add any value, but including it makes the function set complete.
    // Again, the "conn" doesn't do anything, it makes the functions consistent.
    return SendResponseBool( queue, bval);
}

// BT Number functions.

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline char JHSSendRemoteNumber( byte conn, byte queue, long val)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
    char rc;
    until (false)
    {
        Acquire(JHS_BT_mutex);
        if (RemoteConnectionIdle(conn))
            break;
        else
        {
            Release(JHS_BT_mutex);
            Yield();
        }
    }
    rc = SendRemoteNumber(conn, queue, val);
    Release(JHS_BT_mutex);
    return rc;
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline char JHSReceiveRemoteNumber( byte conn, byte queue, bool clear, long &val, bool bwait = true)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
    queue += (conn << 6);
    if (bwait)
    {
        until (NO_ERR == ReceiveRemoteNumber(queue, false, val))
        {
            Wait(1);
            if (bBT_Stop)
            {
                return 1;
                break;
            }
        }
    }
    if (!bBT_Stop)
        { return ReceiveRemoteNumber(queue, clear, val); }
    else
        { return 1; }
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline char JHSSendResponseNumber( byte conn, byte queue, long val)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
    // This doesn't add any value, but including it makes the function set complete.
    // Again, the "conn" doesn't do anything, it makes the functions consistent.
    return SendResponseNumber( queue, val);
}

// BT String functions.

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline char JHSSendRemoteString( byte conn, byte queue, string val)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
    char rc;
    until (false)
    {
        Acquire(JHS_BT_mutex);
        if (RemoteConnectionIdle(conn))
            break;
        else
        {
            Release(JHS_BT_mutex);
            Yield();
        }
    }
    rc = SendRemoteString(conn, queue, val);
    Release(JHS_BT_mutex);
    return rc;
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline char JHSReceiveRemoteString( byte conn, byte queue, bool clear, string &val, bool bwait = true)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
    queue += (conn << 6);
    if (bwait)
    {
        until (NO_ERR == ReceiveRemoteString(queue, false, val))
        {
            Wait(1);
            if (bBT_Stop)
            {
                return 1;
                break;
            }
        }
    }
    if (!bBT_Stop)
        { return ReceiveRemoteString(queue, clear, val); }
    else
        { return 1; }
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline char JHSSendResponseString( byte conn, byte queue, string val)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
    // This doesn't add any value, but including it makes the function set complete.
    // Again, the "conn" doesn't do anything, it makes the functions consistent.
    return SendResponseString( queue, val);
}

// BT float functions

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline char JHSSendRemoteFloat( byte conn, byte queue, float val)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
    char rc;
    string sTemp;

    until (false)
    {
        Acquire(JHS_BT_mutex);
        if (RemoteConnectionIdle(conn))
            break;
        else
        {
            Release(JHS_BT_mutex);
            Yield();
        }
    }
    sTemp = FlattenVar(val);
    rc = SendRemoteString(conn, queue, sTemp);
    Release(JHS_BT_mutex);
    return rc;
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline char JHSReceiveRemoteFloat( byte conn, byte queue, bool clear, float &val, bool bwait = true)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
    char rc;
    string sTemp;

    queue += (conn << 6);
    if (bwait)
    {
        until (NO_ERR == ReceiveRemoteString( queue, false, sTemp))
        {
            Wait(1);
            if (bBT_Stop)
            {
                return 1;
                break;
            }
        }
    }
    if (!bBT_Stop)
        {
            rc = ReceiveRemoteString( queue, clear, sTemp);
            UnflattenVar(sTemp, val);
            return rc;
        }
    else
        { return 1; }
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline char JHSSendResponseFloat( byte conn, byte queue, float val)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
    char rc;
    string sTemp;

    until (false)
    {
        Acquire(JHS_BT_mutex);
        if (RemoteConnectionIdle(conn))
            break;
        else
        {
            Release(JHS_BT_mutex);
            Yield();
        }
    }
    sTemp = FlattenVar(val);
    rc = SendResponseString(queue, sTemp);
    Release(JHS_BT_mutex);
    return rc;
}

mcsummation
Posts: 220
Joined: 23 Jan 2012, 17:07
Location: Round Rock, TX

Re: Bluetooth "extras"

Post by mcsummation »

You should be able to do a #include "BT_Stuff.nxc" (including the " marks) at the top of your program. You don't need to copy all that into your program.

The Master and Slave programs I used to test the code are included.
Last edited by mcsummation on 17 Mar 2012, 18:47, edited 1 time in total.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Bluetooth "extras"

Post by HaWe »

You should be able to do a #include "BT_Stuff.nxc" (including the " marks) at the top of your program.
yes, that's what I did, I didn't copy and paste it of course.

Code: Select all

#include "BT_JHS_TOOLS_H.nxc"
#include "CHESS_AI_MOVE_GENERATOR.nxc"
I just postet the source to make sure that I downloaded the whole correct code both for the master and for the slaves.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Bluetooth "extras"

Post by HaWe »

my master code now looks like this:

Code: Select all

// *SNIP*
#include "BT_JHS_TOOLS_H.nxc"
#include "CHESS_AI_MOVE_GENERATOR.nxc"

#define debug

char _NOS_;  // number of slaves

// The connection channel to the Slave.
#define CONN1 1
#define CONN2 2
#define CONN3 3

// Name of the Slave NXT.
string SLAVE[4] = {"000","001","002","003"};

// tone signals for debug
int  TONE[5] = {TONE_C4,TONE_E4,TONE_G4,TONE_C5,TONE_E5};


char _NOS_; // number of slaves

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bool Init_BT(char max_conn)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
    int iResult;
    bool bSlave1Ready;
    char conn;

    _NOS_ = max_conn;

    // In case it is already connected to something.
    for ( conn=1; conn<=_NOS_; ++conn) {
      DisconnectBT(conn);
    }

    PlayTone(TONE_C4, 200);   Wait(1000);

    for ( conn=1; conn<=_NOS_; ++conn) {
      until (ConnectBT(conn, SLAVE[conn])) ;
      PlayTone(TONE[conn], 200);  Wait(200);
    }

}



/******************************************************************************/
task main(){
/******************************************************************************/
  char EP,                            // flag: en passant
       RK,                            // flag: castling=Rochade
       CK, CM,                        // flag: check!=Schach! (1&8, 1&16)
       turn,                          // side on turn
       chosen;                        // manual or auto move from stdin input;
  char board[129];                    // Piece K_start-> L_dest
  int K, L,                           // score local, remote
      score, rscore1, rscore2, rscore3, idum, buf;
  char PMOD=0, m1, m2, m3;
  string s;


// init all defauts
  Init();
  InitIOports();
  Init_BT(2);


//... *SNIP*

HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Bluetooth "extras"

Post by HaWe »

tomorrow I will have to transcode the following independent master routines (procedure for sending on demand and continuous task for receiving) into your code:

Code: Select all

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
safecall void BTSend(char ID, string cmd) {
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  char INBOX, OUTBOX;

  INBOX = 3*ID;
  OUTBOX= INBOX -2;

  int ack=0;
  int ch=checksum(cmd);
  while (ack!=ch)  {
    SendRemoteString(ID, OUTBOX, cmd);
    do {Wait(1);} while (ReceiveRemoteNumber(INBOX, true, ack)!= NO_ERR);
    ReceiveRemoteNumber(INBOX, true, ack);
    Wait(30);
  }

}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
task ReceiveSlaveData()    // NOS = Number of Slaves
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
   string _msg;
   // dummies
   char  INBOX_11, INBOX_21, INBOX_31;  // dummies
   // dummies
    
   while(true)   {
     if (_NOS_>=1) {
       do {Wait(1);} while(ReceiveRemoteString(INBOX_11, true, _msg) != NO_ERR);
       ParseBTResponseMsg(0, _msg) ;
       Wait(10);
     }

     if (_NOS_>=2) {
       do {Wait(1);} while(ReceiveRemoteString(INBOX_21, true, _msg) != NO_ERR);
       ParseBTResponseMsg(1, _msg) ;
       Wait(10);
     }

     if (_NOS_==3) {
       do {Wait(1);} while(ReceiveRemoteString(INBOX_31, true, _msg) != NO_ERR);
       ParseBTResponseMsg(2, _msg) ;
       Wait(10);
      }

     Wait(30);
   }
}


and for each slave, I will have to transcode this - I'm still curious how the slave code has to be using your BT_stuff..

Code: Select all

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
task BTReceive() {
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  string in;
  int ack, len;

  while(true) {
    in= "  ";

    if (ReceiveRemoteString(INBOX, true, in) != STAT_MSG_EMPTY_MAILBOX)
    {
       ack=checksum(in);
       SendResponseNumber(OUTBOX_2, ack);   //  check
       Wait(1);
       __cmd=in;
       start ExecCmd;
    }
    Wait(20);
  }
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
task BTMBxWrite() {
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  string sp, sn, svv;
  string fmtstr, buf, out;
  int i, dec;


  while(true)   {
     out="";
     for(i=0; i<11; i++)   // Sensorports: 0...3  plus virtual ports
     {
        GetSensorValues(i);
        Wait(1);

        dec=SensorValueDecimals[i];
        sn=NumToStr(dec);                          // value decimals
        fmtstr=StrCat("%",NumToStr(dec),"d");
        svv=FormatNum(fmtstr,SensorCurrArr);

        out = StrCat(out, sn, svv);

     } //  for port=...

     if (StrLen(out)>58) strncpy(out,out,58);     // 58 = max msg length
     SendResponseString(OUTBOX_1, out);
#ifdef debug
      //TextOut(0, 0, out);
#endif

     Wait(20);

  } // while(true)
}
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Bluetooth "extras"

Post by HaWe »

JHS,
I'm sorry but I don't understand your code examples for master and slave and how I have to adjust the code to my already existing code.

So, first step:
could you please explain a little more detailed how to use

Code: Select all

JHSReceiveRemote…    - connection_number, mailbox_number, clear, location to return the value, wait
and
WaitBT(Conn)
instead of

Code: Select all

 do {Wait(1);} while(JHSReceiveRemoteString(INBOX_11, true, _msg) != NO_ERR);
?

In your new code (compared to the ReceiveRemoteString syntax) for
JHSReceiveRemote
there seemes to be 1 function parameter missing if I compile, and I don't know which -
the error message I get is:
# Error: ',' expected
File "c:\Temp\temp.nxc" ; line 191
# do {Wait(1);} while(JHSReceiveRemoteString(2, true, _msg) !
#----------------------------------------------------------
# Error: Identifier expected
File "c:\Temp\temp.nxc" ; line 191
# do {Wait(1);} while(JHSReceiveRemoteString(2, true, _msg) !=
#----------------------------------------------------------
# Error: Undefined Identifier !
File "c:\Temp\temp.nxc" ; line 191
# do {Wait(1);} while(JHSReceiveRemoteString(2, true, _msg) !=
#----------------------------------------------------------
# Error: Expressions are not supported for struct, array, or reference parameters
File "c:\Temp\temp.nxc" ; line 191
# do {Wait(1);} while(JHSReceiveRemoteString(2, true, _msg) != 0);
#----------------------------------------------------------
# Error: ')' expected
File "c:\Temp\temp.nxc" ; line 192
# P
#----------------------------------------------------------
# Error: ',' expected
File "c:\Temp\temp.nxc" ; line 197
# do {Wait(1);} while(JHSReceiveRemoteString(5, true, _msg) !
#----------------------------------------------------------
# Error: Identifier expected
File "c:\Temp\temp.nxc" ; line 197
# do {Wait(1);} while(JHSReceiveRemoteString(5, true, _msg) !=
#----------------------------------------------------------
# Error: Undefined Identifier !
File "c:\Temp\temp.nxc" ; line 197
# do {Wait(1);} while(JHSReceiveRemoteString(5, true, _msg) !=
#----------------------------------------------------------
# Error: Expressions are not supported for struct, array, or reference parameters
File "c:\Temp\temp.nxc" ; line 197
# do {Wait(1);} while(JHSReceiveRemoteString(5, true, _msg) != 0);
#----------------------------------------------------------
# Error: ')' expected
File "c:\Temp\temp.nxc" ; line 198
# P
#----------------------------------------------------------
# Error: ',' expected
File "c:\Temp\temp.nxc" ; line 203
# do {Wait(1);} while(JHSReceiveRemoteString(8, true, _msg) !
#----------------------------------------------------------
# Error: Identifier expected
File "c:\Temp\temp.nxc" ; line 203
# do {Wait(1);} while(JHSReceiveRemoteString(8, true, _msg) !=
#----------------------------------------------------------
# Error: Undefined Identifier !
File "c:\Temp\temp.nxc" ; line 203
# do {Wait(1);} while(JHSReceiveRemoteString(8, true, _msg) !=
#----------------------------------------------------------
# Error: Expressions are not supported for struct, array, or reference parameters
File "c:\Temp\temp.nxc" ; line 203
# do {Wait(1);} while(JHSReceiveRemoteString(8, true, _msg) != 0);
#----------------------------------------------------------
# Error: ')' expected
File "c:\Temp\temp.nxc" ; line 204
# P
#----------------------------------------------------------



thx in advance!
mcsummation
Posts: 220
Joined: 23 Jan 2012, 17:07
Location: Round Rock, TX

Re: Bluetooth "extras"

Post by mcsummation »

Instead of your code

Code: Select all

    do {Wait(1);} while(JHSReceiveRemoteString(INBOX_11, true, _msg) != NO_ERR);
you would use simply

Code: Select all

JHSReceiveRemoteString(connnection_number, INBOX_11, true, msg);
The connection number is supplied on all my function calls - uniform set of parameters and will only ask one slave for data. It will also wait for a message to arrive.

For the errors, you have probably left off the connection_number.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests