[Help] Problem sending datas through Bluetooth
Page 1 of 1

Author:  Daxid [ Tue Nov 11, 2014 9:44 am ]
Post subject:  [Help] Problem sending datas through Bluetooth

I'm developing a program in C which send datas of a sensor (AbsoluteIMU from mindsensor but it isn't the point). I'm using the command cCmdWriteToBluetooth since need to send 8 datas per package. My idea is to develop a SW on my PC to use these datas. Before doing it I use Docklight (I also tried RealTerm) to monitor the COM port on my PC and sending Direct Commands (StartProgram, StopProgram and other commands to test it).

Here is my problem:
When I send the Direct Command StartProgram (which is sent correctly) or when I start the program on the NXT with the port COM openm, the program on the NXT start, I receive the packages with my datas, and all works fine. But if I want to send another Direct Command (no matter what it is), it send it but the NXT seems not receiving it (no response even when the command asked for it and nothing starts/is received on the pc). I need to close the connection and open it again before doing anything else otherwise the Bluetooth crashes and I need to restart the NXT by removing the power supply. The problem only happens when I start a program which sends datas from the NXT. After that I can't send any Direct Command.

Here is the code I use on the NXT:

#pragma config(Sensor, S1,     MSIMU,          sensorI2CCustomFastSkipStates)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "mindsensors-imu.h"

const ubyte array_Length = 8 ; //number of datas bytes sent via BT

task main()
   wait10Msec (100);

   time1 [T1] = 0; //reset T1

   ubyte array_test [array_Length]; //array which will contain values sent via BT

   int x_val, y_val, z_val, time_Elapsed;      // axis values

   while (true)
      time_Elapsed = time1 [T1];
      MSIMUreadAccelAxes(MSIMU, x_val, y_val, z_val);

      array_test [0] = (ubyte) (x_val & 0x00FF);
      array_test [1] = (ubyte) ((x_val & 0xFF00)>>8);
      array_test [2] = (ubyte) (y_val & 0x00FF);
      array_test [3] = (ubyte) ((y_val & 0xFF00)>>8);
      array_test [4] = (ubyte) (z_val & 0x00FF);
      array_test [5] = (ubyte) ((z_val & 0xFF00)>>8);
      array_test [6] = (ubyte) (time_Elapsed & 0x00FF);
      array_test [7] = (ubyte) ((time_Elapsed & 0xFF00)>>8);

      cCmdMessageWriteToBluetooth(array_test, array_Length, mailbox1);
      wait1Msec (50); //I'm currently testing the time between each measure

I'm using RobotC 3.62 on Windows 7.

So what do you think it can be and what can I do to avoid getting this problem?

Thank you


Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group