k3ng / k3ng_rotator_controller

K3NG Arduino Amateur Radio Rotator Controller
http://blog.radioartisan.com/yaesu-rotator-computer-serial-interface/
GNU General Public License v3.0
181 stars 126 forks source link

Empty lines as response for GS-232B commands? #76

Closed mikaelnousiainen closed 3 years ago

mikaelnousiainen commented 4 years ago

I've been trying to use a very recent version of the K3NG rotator controller firmware (running in a RemoteQTH rotator interface) with latest Hamlib 4.x master code. The get/set azimuth commands do work, but Hamlib gets sometimes confused about the empty line feed characters (0x0A) sent back by K3NG as a response to the W command to set AZ/EL. Hamlib GS-232B backend doesn't expect any response for the W command.

I'm seeing this println command in K3NG code: https://github.com/k3ng/k3ng_rotator_controller/blob/master/k3ng_rotator_controller/k3ng_rotator_controller.ino#L3605 which I believe is the reason for the empty lines.

My question here is: Are the new lines allowed by the GS-232B protocol as a response or should an empty string in the response text result in nothing to be sent back at all (instead of a new line)? I haven't yet found detailed documentation on the protocol regarding what's allowed and what is not :)

Here's the related issue/question in Hamlib repo: https://github.com/Hamlib/Hamlib/issues/371

mikaelnousiainen commented 4 years ago

I'm seeing this being stated about the GS-232B and GS-232A protocols:

"Most commands have two versions: one for azimuth, and one for elevation. Commands are not echoed by the Control Interface, but a carriage return character (“0Dh”) is returned after every command, and also a line feed character (“0Ah”) if the command invoked returned data. Invalid commands cause “? >” to be returned and the input buffer cleared."

So basically what should be returned by every command is a carriage return (0x0D) and not a line-feed (0x0A), unless there is a response from the command.

Anyway, it seems even Hamlib should be accepting carriage returns too, but do you think this would warrant a change in K3NG responses for GS-232A and B?

See these links for GS-232A and GS-232B references:

mikaelnousiainen commented 3 years ago

@k3ng Any ideas about this possible incompatibility with Hamlib?

mikaelnousiainen commented 3 years ago

This was fixed in Hamlib by adding a post write delay after each command.