Here is the background. I am trying to write a service for the HiTechnic prototype board.
Using the Appendix 2 from the blue tooth developers kit from Lego's site I am able to understand what is going on with this service I am trying to build however the response I get is always 221 = 0xDD = "Communication Bus Error" or 32 = 0x20 = "Pending communication transaction in progress".
I figured out that the HiTechnic prototype board is using i2c address 0x08 so I modified the brick code to use that address instead of the standard 0x02. It goes out and configures the device, I get a response and then it does an LSWrite which seems OK then I get a get an error when it does the LSGetStatus.
I know this thing works - I can bit bang it all day long with an Arduino but I only did that to test it out - see this link
I am not sure what else to try. Here is how I am setting it up in the connect to brick handler.
pxbrick.Registration registration = new pxbrick.Registration(
new LegoNxtConnection(LegoNxtPort.Sensor1),
LegoDeviceType.DigitalSensor,
Contract.DeviceModel,
Contract.Identifier,
ServiceInfo.Service,
_state.Name);
Debugger.Break();
// Reserve the port
LogInfo("ConnectToBrickHandler");
yield return Arbiter.Choice(_legoBrickPort.ReserveDevicePort(registration),
delegate(pxbrick.AttachResponse reserveResponse)
{
Debugger.Break();
if (reserveResponse.DeviceModel == registration.DeviceModel)
{
registration.Connection = reserveResponse.Connection;
}
},
delegate(Fault f)
{
Debugger.Break();
fault = f;
LogError("#### Failed to reserve port");
LogError(fault);
registration.Connection.Port = LegoNxtPort.NotConnected;
});
I have also tried setting AnyPort as well so that it will hit the TestPortForI2CSensorHandler that just does what I explained before - it seems to set the mode fine and then gets an error when it tries to read the device information.
Here is the data. - this first part is the set input more - both the message and response - You can see it is totally fine.
Send command data.
0
5
0
11
0
receive command data. (_commState.SerialPort.Read(receiveData, 0, packetSize);)
2
5
0
Then it does an LSWrite - everything still seems fine... You can see I have modified the NxtComm code to use 0x08 instead of 0x02 which it would normally use, then the last byte is also 0x08 which is the starting address of the manufacturer. It's asking for 16 bytes which would be the manufacturer and sensor type. like I said - I know that works I can print that info out using the Arduino.
128
15
0
2
16
8 // i2c address
8 //I assume this is what address I want to read from?
Got response: True Error code Success [02/25/2013 02:20:31]
-- SendCommandHandler (NxtComm) [02/25/2013 02:20:31]
--- RequestResponseHandler (NxtComm) [02/25/2013 02:20:31]
--- CommSendImmediateHandler (NxtComm) [02/25/2013 02:20:31]
Send command data.
Then it tries to get the status
0
14
0
Here is the response...
2
14
32
0
It's either 32 or 221. It's making me nuts...
If anyone has anything that might help me out I would so much appreciate it. At this point I am running out of ideas. I can see what is going on, I can understand the entire transaction but can't seem to figure out why it just errors out like that.
Also - just for grins I tried 0x10 which is what they tell you on the HiTechnic website. That gets a response of 2,14,0,0 from the NXT brick - that would indicate there is no data but as I pointed out I can get data using the Arduino. How could I have two different I2C device addresses?