Jrk g2 feedback with c#

i did use this c# code for sending target to jrkg2 over usb:

command[0] = (byte)(0xC0 + (target & 0x1F));
command[1] = (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).


////get scaledfeedback

                    byte[] command2 = new byte[1];
                    command2[0] = 0xA7;
                    spAutoSteer.Write(command2,0, 1);

byte[] buffer = new byte[2];

                        spAutoSteer.Read(buffer, 0, 2);
                       int feedback = buffer[0] + 256 * buffer[1];

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.


thanks working now.

i did pull to fast…