This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Write and Read 2540 Dongle through Com-Port via C# Script in Unity

Hello,

I have DevKit with SensorTag and Dongle 2540. I want to communicate via a C# Script with the dongle.To get some understanding I wanted to begin with the command "01091000", which should tell the dongle to return its board adress. After writing to the port I try to read with port.ReadByte(), but I am getting timeouts.

I know there are many examples I could go through, but I think it would help me more if someone could provide a short code-snippet where this (or the init) command is written on the port and reading it afterwards.

Help would be much appreciated.

  • Hello,

    Hopefully someone with C# experience can jump in here. In the meantime, I would suggest using a UART virtual sniffer to dump the actual bytes going to/from the dongle. That should give you some feedback as to if the HCI commands are being formulated properly.

    Best wishes

  • Thank you, I didn't think of that thing with the sniffer. I am kind of new to that topics. For the mentioned command 01091000 the sniffer says it dumps

    30 31 30 39 31 30 30 30   

    So it seems that just writing the hex-code as string to the port gets somehow converted. I'll do some research on that.

  • Again, thank you for that hint with the sniffer, I am now able to write and receive the response. If someone else behaves as stupidly as me, this seems to be the correct syntax for this:

    byte[] vals = { 0x01, 0x09, 0x10, 0x00 };
    port.Write(vals, 0, vals.Length);