Arduino-hamlib-gpredict disengaging

I am trying to run following combination: Gpredict 2.3.37 on windows10, hamlib-w64-4.5.5 started with cmd file containing

set ROTCTLD=D:\Ham\hamlib-w64-4.5.5\bin\rotctld.exe

set ROTTYPE=202

set ROTPORT=COM7

set ROTRATE=9600

start /min “Rotator Control” %ROTCTLD% -m %ROTTYPE% -r %ROTPORT% -s %ROTRATE% -T 127.0.0.1 -t 4533 -vvvvvv

start /wait %GPREDICT%

and arduino dummy code to display gpredict data on 16x2 i2c display.

data = Serial.readStringUntil('\n');  // Read data until newline character

// Find "AZ" and "EL" substrings in the data
int azIndex = data.indexOf("AZ");
int elIndex = data.indexOf("EL");

if (azIndex != -1) {
//Extract the number following "AZ"
azValue = extractNumber(data.substring(azIndex + 2));
}

if (elIndex != -1) {
// Extract the number following "EL"
elValue = extractNumber(data.substring(elIndex + 2));
}

Data are properly displayed as desired when gpredict is engaged (once) and after short time gpredict is disengaged and no further updates on arduino display (except AZ EL 4x and then SA SE). I see in gpredict log

2024/03/17 11:11:57|1|…/src/gtk-rot-ctrl.c:322: rotctld returned error (RPRT -5)

2024/03/17 11:11:58|1|…/src/gtk-rot-ctrl.c:322: rotctld returned error (RPRT -5)

2024/03/17 11:11:59|1|…/src/gtk-rot-ctrl.c:322: rotctld returned error (RPRT -5)

2024/03/17 11:12:00|1|rot_ctrl_timeout_cb: MAX_ERROR_COUNT (5) reached. Disengaging device!

Next manual engaging will again pass data to arduino and are displayed as I need, but I would like to keep it up and running (without manual re-engaging) until I want to disengage. What am I doing wrongly? Should arduino send some ack information to hamlib or rotctld parameters are missing anything important? Thanks for any direction. Peter.

Hi,
trying to understand what you want to accomplish here, just displaying the angles or is this only for testing ?
The arduino is the only thing rotctld is communicating with ?
Are you running a rotator that you want to control ?

Anyways, loos like easycomm, I’m not super familiar with that protocol, but it seems that rotctld is expecting a response on one of the commands gpredict sent. In the absense of this response, it disengages the device as it doesn’t respond properly.

Depending on that you are trying to accomplish, you might need to implement more easycomm commands and send the appropriate responses to them.

Hi, thanks, now just displaying angles on arduino I2C display, nothing more, no rotor connected (yet), just want to understand communication details instead of usage of some megauniversal piece of code which I understand hardly or not at all. I found in easycomm definition, that: “For those commands that require a response, the response is an echo of the command followed by the response.”. This is not my case I assume as AZ EL command set angles only. So maybe it could be not this “application protocol” related, but maybe some low level COM/USB emulator incompatibility, I have chinese CH340, although latest 2019 version.

My point is that gpredict and other control sw will send a bunch of commands, not just the bare minimum. This assumption should be questioned, for example by displaying any unhandled lines.
I’m pretty sure gpredict uses the hamlib p command to read position, this results in AZ EL in easycomm, that requires a response like AZ123.4 EL12.3.

Daniel,thanks. Following is a log of hamlib communication. There is a sequence “AZ EL” and once after AZ/EL there are values of angles with one decimal place. After 5 errors there is command SA SE to stop rotator, because easycomme did not receive some information from rotator (error -5). And my problem is that I am unable to find what this error means and actually also whether this error comes from hamlib (code.tools/man/8/rotctld, GitHub - Hamlib/Hamlib: Ham radio control library for rigs, rotators, tuners, and amplifiers).

<<<<< gpredict and rotcltd started >>>>>

rotctld, Hamlib 4.5.5 Apr 05 11:43:08Z 2023 SHA=6eecd3
Report bugs to hamlib-developer@lists.sourceforge.net

rot_init called
initrots4_easycomm called
rot_register (201)
rot_register (202)
rot_register (204)
set_conf: called
rot_open called
serial_open: COM7
serial_setup: tcgetattr
serial_setup: cfsetispeed=9600,0x000d
serial_setup: cfsetospeed=9600,0x000d
serial_setup: data_bits=8
serial_setup: parity=0
serial_setup: Handshake=None
serial_setup: tcsetattr TCSANOW
read_string_generic called, rxmax=4095 direct=1, expected_len=1
tcflush
Opened rot model 202, ‘EasycommII’
Backend version: 20191206.0, Status: Stable

<<<<< here I press engage>>>>>

Connection opened from 127.0.0.1:51229
rotctl(d): p ‘’ ‘’ ‘’ ‘’
rot_get_position called
easycomm_rot_get_position called
easycomm_transaction called: AZ EL

rig_flush: called for serial device
read_string_generic called, rxmax=4095 direct=1, expected_len=1
tcflush
write_block(): TX 7 bytes, method=2
0000 41 5a 20 45 4c 20 0a AZ EL .
read_string_generic called, rxmax=32 direct=1, expected_len=1
read_string_generic(): Timed out 0.309 seconds after 0 chars, direct=1
easycomm_transaction read_string failed with status -5
easycomm_rot_get_position got error: -5
rotctl_parse: NETROTCTL_RET -5
rotctl(d): p ‘’ ‘’ ‘’ ‘’
rot_get_position called
easycomm_rot_get_position called
easycomm_transaction called: AZ EL

rig_flush: called for serial device
read_string_generic called, rxmax=4095 direct=1, expected_len=1
tcflush
write_block(): TX 7 bytes, method=2
0000 41 5a 20 45 4c 20 0a AZ EL .
read_string_generic called, rxmax=32 direct=1, expected_len=1
read_string_generic(): Timed out 0.309 seconds after 0 chars, direct=1
easycomm_transaction read_string failed with status -5
easycomm_rot_get_position got error: -5
rotctl_parse: NETROTCTL_RET -5
rotctl(d): P ‘199,57’ ‘56,61’ ‘’ ‘’
rot_set_position called az=199.57 el=56.61
rot_set_position: south_zero=0
easycomm_rot_set_position called: 199.570007 56.610001
easycomm_transaction called: AZ199.6 EL56.6

rig_flush: called for serial device
read_string_generic called, rxmax=4095 direct=1, expected_len=1
tcflush
write_block(): TX 15 bytes, method=2
0000 41 5a 31 39 39 2e 36 20 45 4c 35 36 2e 36 0a AZ199.6 EL56.6.
rotctl_parse: NETROTCTL_RET 0
rotctl(d): p ‘’ ‘’ ‘’ ‘’
rot_get_position called
easycomm_rot_get_position called
easycomm_transaction called: AZ EL

rig_flush: called for serial device
read_string_generic called, rxmax=4095 direct=1, expected_len=1
tcflush
write_block(): TX 7 bytes, method=2
0000 41 5a 20 45 4c 20 0a AZ EL .
read_string_generic called, rxmax=32 direct=1, expected_len=1
read_string_generic(): Timed out 0.307 seconds after 0 chars, direct=1
easycomm_transaction read_string failed with status -5
easycomm_rot_get_position got error: -5
rotctl_parse: NETROTCTL_RET -5
rotctl(d): p ‘’ ‘’ ‘’ ‘’
rot_get_position called
easycomm_rot_get_position called
easycomm_transaction called: AZ EL

rig_flush: called for serial device
read_string_generic called, rxmax=4095 direct=1, expected_len=1
tcflush
write_block(): TX 7 bytes, method=2
0000 41 5a 20 45 4c 20 0a AZ EL .
read_string_generic called, rxmax=32 direct=1, expected_len=1
read_string_generic(): Timed out 0.308 seconds after 0 chars, direct=1
easycomm_transaction read_string failed with status -5
easycomm_rot_get_position got error: -5
rotctl_parse: NETROTCTL_RET -5
rotctl(d): p ‘’ ‘’ ‘’ ‘’
rot_get_position called
easycomm_rot_get_position called
easycomm_transaction called: AZ EL

rig_flush: called for serial device
read_string_generic called, rxmax=4095 direct=1, expected_len=1
tcflush
write_block(): TX 7 bytes, method=2
0000 41 5a 20 45 4c 20 0a AZ EL .
read_string_generic called, rxmax=32 direct=1, expected_len=1
read_string_generic(): Timed out 0.348 seconds after 0 chars, direct=1
easycomm_transaction read_string failed with status -5
easycomm_rot_get_position got error: -5
rotctl_parse: NETROTCTL_RET -5
rotctl(d): p ‘’ ‘’ ‘’ ‘’
rot_get_position called
easycomm_rot_get_position called
easycomm_transaction called: AZ EL

rig_flush: called for serial device
read_string_generic called, rxmax=4095 direct=1, expected_len=1
tcflush
write_block(): TX 7 bytes, method=2
0000 41 5a 20 45 4c 20 0a AZ EL .
read_string_generic called, rxmax=32 direct=1, expected_len=1
read_string_generic(): Timed out 0.373 seconds after 0 chars, direct=1
easycomm_transaction read_string failed with status -5
easycomm_rot_get_position got error: -5
rotctl_parse: NETROTCTL_RET -5
rotctl(d): S ‘’ ‘’ ‘’ ‘’
rot_stop called
easycomm_rot_stop called
easycomm_transaction called: SA SE

rig_flush: called for serial device
read_string_generic called, rxmax=4095 direct=1, expected_len=1
tcflush
write_block(): TX 7 bytes, method=2
0000 53 41 20 53 45 20 0a SA SE .
rotctl_parse: NETROTCTL_RET 0
Connection closed from 127.0.0.1:51229

In the meantime I have found some documented issues with CH340 serial/USB chips as a frequent substitution of ft232 in chinese arduino nano clones, so first I downgraded the CH340 driver by two generations back and finally replaced nano with original arduino mega with different USB communication. Unfortunately the same error -5 :-(.

the serial driver is the wrong rabbit hole afaict. I have been running those ch340 for many years, with xp, win7, win11, different linux dists etc.

if you want to emulate the easycomm rotator you must implement the responses gpredict expects, as commanded by hamlib. in this case at least the AZ EL. this means you need to save the az and el values sent and send them back when asked for. this will at least not disengage after 5 errors from not responding.

three commands needs to be implemented; AZxxx.x ELyyy.y and AZxxx.x ELyyy.y and handling different number lengths. I’d split by space and loop through each and search for AZ and EL, then save the rest in a respective variable, to be sent out when requested by AZ EL in the format of AZxxx.x ELyyy.y

this leads to the next thing, what is it going to be used for ? gpredict already shows the wanted and actual position. if this display/emulation is only a temporary thing it is some work for pretty much nothing. how is it going to be used with a real rotator ?

Good afternoon, I solved it by changing the version of hamlib after months of seeing what happened.

Julio LW2DYB

Thanks for comments, issue was incorrect response to AZ EL command and following solution works as desired. azValue/elValue are NNN.N or NN.N formatted strings obtained from rotator sensor or generated by whatever. Second important condition to get it work is Tolerance setting in gpredict control window, where you set tracked sat and engaged device, you need to reduce Tolerance to reasonable minimum, otherwise the difference between desired position and position instruction to rotator will be sent only after major deviation (default is 5deg), which is visible after some time only…

void loop() {
if (Serial.available() > 0) {
String data = Serial.readStringUntil(0x0A);
data.trim();

int azIndex = data.indexOf("AZ");
int elIndex = data.indexOf("EL");

if (azIndex != -1 && elIndex != -1) {
  Serial.print("AZ" + azValue + " EL" + elValue);
  Serial.print(char(0x0A));

  String azValuetmp = extractNumber(data.substring(azIndex + 2));
  String elValuetmp = extractNumber(data.substring(elIndex + 2));

  if (azValuetmp.length() > 0 && elValuetmp.length() > 0) {
    azValue = azValuetmp;
    elValue = elValuetmp;

    //lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("AZ:");
    lcd.print(azValue);
    lcd.print(" EL:");
    lcd.print(elValue);
  }
}

}

1 Like

Good morning just wondered what version you used
many thanks
Peter(G4GRK)

Good morning, the version of hamlib that I used on Windows and it doesn’t give me an error is hamlib w32 3.2