Reply To: Sonar Sensor with C++ Library (NXT)

HomeForumsMonoBrick Communication LibrarySonar Sensor with C++ Library (NXT)Reply To: Sonar Sensor with C++ Library (NXT)

#5317
Author Image
Joe Smith
Participant

Thanks for the reply.

Sadly, it didn’t help.

a) i moved the construction of the sensors and motor inside the try-brackets, with the sensor3 directly followed by its init(), which just resulted in the same error occuring after the 500 ms delay defined in the i2c.h

b) i tried both setups without the tunnel, which runs, but complains:

E
error code 352
error type 1
in Function “send” in class “Nxt_network”

when the program tries to execute the line:

"connection->connect(1500, "127.0.0.1");"

which i guess means it can’t find the nxt without the tunnel. Sadly i can’t try it with bluetooth, as i don’t have a bluetooth connecting-thingy anywhere.

interesting sidenote:
the problem seems to be created by the Read()-commands, as the init() command runs fine, when i change the init()function in sonar.cpp from

void Sonar::init(bool reply){
  I2c::init(reply);
  read();
  read();
  off();
  this->has_init=true;
}

to

void Sonar::init(bool reply){
  I2c::init(reply);
  //read();
  //read();
  off();
  this->has_init=true;
}

after this change, the error occurs after the touch-sensor press again, when the read-command is executed.
(i might be wrong, however, since, maybe, the init() fails without anyone noticing, preventing the read() from working afterwards, simply because the sensor is not initialised?

anyway, it doesn’t work with init(true) either, same error message, which i guess means that the initialisation works fine, as the ‘true’ would mean that the nxt responds?

sorry for the wordyness and thanks again

Joe

Posted in

Make a donation