I have been trying to write code to connect a HiTechnic prototype board to my lego brick. Although I am using MSRDS studio, that isn't the issue; reading and writing to the serial port that the device is connected to works fine.

Where I am lacking is that I don't understand the data is that is being sent and received. It goes out and comes back in the form of a byte array. For example: [128] [15] [0] [2] [16] [2] [8]

Is this byte array converted from hex? What is this response telling me?

Obviously I am a total newbie at this, I can program but I don't really understand electronics and I am trying to make that connection between what I have read about how an I2C controller works and what is happening when I send and receive data over a serial port.

  • 1
    $\begingroup$ I've added a link in your question to what I assume is the product in question. Can you confirm that? $\endgroup$
    – Ian
    Jan 25, 2013 at 16:21
  • $\begingroup$ So yeah! That's the device. As far as you second question. All I know is that I threw a for loop in that does a console log to tell me the values of the byte array and that is what I got out of it. I know for sure that the NxtComm.cs service is using the Serial port class in System.IO.Ports to read and write to the device. So... That's the most I can offer you. That you so much for responding though. $\endgroup$
    – Kenn
    Jan 26, 2013 at 1:50
  • 1
    $\begingroup$ "a serial port sends and receives 7-bit ASCII characters" ?? Not that I've encounter since the 70's. $\endgroup$
    – Spiked3
    Jan 26, 2013 at 3:20
  • $\begingroup$ @Ian - I'd best redesign the serial link I'm using at work, which is using a full 8 data bits for 0x00-0xFF (unsigned) (or sometimes 0xFF-0x7F (signed data) ;-P $\endgroup$
    – Andrew
    Jan 26, 2013 at 8:27
  • 1
    $\begingroup$ No more stackexchange before 9am :) I think I was trying to illustrate that I2C and serial were not the same thing, and went off the deep end. And I've set 8-N-1 enough times to know better. $\endgroup$
    – Ian
    Jan 26, 2013 at 21:45

1 Answer 1


Your question is not clear. "Is this byte array converted from hex?" If you know what the values are, you should know how you got them. 128 is not a hex number, it is the same as a hex 80, also written as 0x80. It indicates a 'Direct command, reply not required' as a serial to NXT stream. 15 = 0x0F = LSWRITE.

It does not make sense to decode any more, as it is your program but you have not told us what you are trying to do and how you are trying to do it.

Just to be clear, there is NO connection between the serial port (usb or bluetooth) and the i2c bus. But the LSWRITE/LSREAD would be the appropriate direct commands (I was wrong earlier, had to look at it some more). I would suggest starting on just the NXT using NXC or LeJOS or RobotC and getting an understanding of the I2C protocol before trying to extend that to a remote PC connection with MRDS.

Start here And download all the PDFs. They describe the command that can be sent over the PC to NXT serial link.

I2C is another step. Start with the Wiki. But you will find that LEGO vendors often do not completely implement the protocol, or they implement it incorrectly. You pretty much need to analyse each device and adjust how you treat it.

enter image description here

I would suggest something like the Saleae logic to analyse what is actually happening.

  • $\begingroup$ Thanks for the info, to be clear all I am trying to do is write a service that will connect to the device, just like a bumper sensor or whatever. Check out this link social.msdn.microsoft.com/Forums/en-US/roboticstroubleshooting/… I put a bunch of debugging in the NxtBrick.cs and can watch it try to connect and then say "Yeah, here is a the device" but then it keeps getting a bus error and resetting. In the meantime I will look into that info you linked to. Again, I know nothing about this I don't even know where to look for stuff. Thanks! $\endgroup$
    – Kenn
    Jan 27, 2013 at 17:02
  • $\begingroup$ particularly - my last post in that link. $\endgroup$
    – Kenn
    Jan 27, 2013 at 17:03
  • $\begingroup$ I would definitely skip mrds until you got the i2c worked out. From that posts I see several bus resets, something that commonly happens when the protocol is not implemented, as I alluded to before. Keep it simple (no mrds) and get a probe on the wire. One thing I've seen several times is multi byte responses that can only be retrieved one byte at a time, or the other way around, byte at a time doesn't work when it should. I do agree with the last comment about x41 address. "The SuperPro uses I2C device address of 0x10" according to the web page. $\endgroup$
    – Spiked3
    Jan 27, 2013 at 18:13
  • $\begingroup$ OK! Thanks for your input I am going to look into NXC or something like that. $\endgroup$
    – Kenn
    Jan 28, 2013 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.