i did use this c# code for sending target to jrkg2 over usb:
command = (byte)(0xC0 + (target & 0x1F));
command = (byte)((target >> 5) & 0x7F);
spAutoSteer.Write(command, 0, 2);
now i am hanging with getting scaled feedback from the controller…
i know i need to send the request to the controller but i not able to to this coding…
maybe someone can help me .
It is not clear what part of the process you have questions about. Note that the scaled feedback value is split into two bytes, similarly to how the target is split into two bytes in the command you posted. There are multiple ways you could go about reading the scaled feedback value, but the simplest way is probably to send the one-byte command that returns both the low and high bytes of the scaled feedback value (0xA7). You can see more about this in the “Serial command encoding” section of the Jrk G2 user’s guide. Once you have the low and high bytes returned from the controller, you can put them together to get the scaled feedback.
If you have any additional questions, please try to be as specific as possible (e.g. what are you trying and what is happening that is not expected).
byte command2 = new byte;
command2 = 0xA7;
byte buffer = new byte;
spAutoSteer.Read(buffer, 0, 2);
int feedback = buffer + 256 * buffer;
is this the right command?
… if i write i once it works - if i do it several times my code crashes…
I suspect you might not be waiting long enough for the Jrk to return the two bytes before trying to read them. I think you might not be using a blocking function to read; you should check the return value of
Read to make sure it’s actually returning two bytes. Alternatively, you can consider using
ReadByte which is blocking.