Giter Site home page Giter Site logo

yapiolibs / hamlib-rotctl-easycomm-parser Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 268 KB

Easycomm parser library for Hamlib rotator control (written in C for C and C++ projects)

License: Apache License 2.0

C 48.88% C++ 36.95% Shell 0.47% Python 13.69%
easycomm hamlib parser platformio platformio-library rotctld

hamlib-rotctl-easycomm-parser's Introduction

Hamlib rotctl Easycomm parser PlatformIO Registry

A PlatformIO parser library for Hamlib rotator control commands.

  • Parses the string-based protocol as described by Easycomm standards I, II or III.
    • from string to C-struct (reception)
    • from C-struct to string (response)
    • Commands reference
  • Programmed with less dependencies in C for C and C++ projects.
    • can be used without the PlatformIO framework
    • not exclusively for micro cotrollers
    • depends on scanf and printf
  • Requires float support for scanf and printf.

Integrate in project example

# platformio.ini
[env:xxx]
platform  = xxx # one of ["native", "atmelavr", "ststm32", "espressiv8266", "espressif32"]
board     = xxx
framework = arduino
lib_deps  = rubienr/HamlibRotctlEasycommParser
# some platforms require folat support for scanf/printf to be explicitely enabled
build_flags =
    # if platfrom is atmelavr:
    -Wl,-u,vfscanf,-lscanf_flt,-u,vfprintf,-lprintf_flt
    # if platform is [...]

Parse a single command example

// main.c
void setup() {}

void loop()
{
    EasycommData result;

    easycommData(&result);
    if(easycommParseCommand("AZ000.1 EL000.0 UP000000000 UUU DN000000000 DDD", &result, EasycommParserStandard1))
    {
        // standard 1 command was parsed
    }

    easycommData(&result);
    if(easycommParseCommand("AZ100", &result, EasycommParserStandard2))
    {
        // standard 2 command was parsed
    }

    easycommData(&result);
    if(easycommParseCommand("VU50", &result, EasycommParserStandard23))
    {
        // standard 3 command was parsed
    }
}

Parse with callback example

// main.c
void customCallback(const EasycommData *command, void *custom_data)
{
    *((bool *)custom_data) = true;
}

void setup() {}

void loop()
{
    // registry for possible callbacks (CB) for each command; CBs may be nullptr
    EasycommCommandsCallback cb_handler;

    // register empty SB stubs for all commands described in standard 2
    easycommCommandsCallback(&cb_handler, EasycommParserStandard2);

    // override a specific CB
    cb_handler.registry[EasycommIdAzimuth] = customCallback;

    bool some_cb_invoked = { false };
    bool custom_cb_invoked = { false };

    some_cb_invoked = easycommHandleCommand("EL100.1", &cb_handler, EasycommParserStandard2, &custom_cb_invoked);
    // custom_cb_invoked == false because customCallback(...) was regitered for AZ but not EL
    // command some_cb_invoked == true because a default empty CB was called for EL command

    some_cb_invoked = easycommHandleCommand("AZ100.1", &cb_handler, EasycommParserStandard2, &custom_cb_invoked);
    // custom_cb_invoked == true
    // some_cb_invoked == true

    some_cb_invoked = easycommHandleCommand("VU", &cb_handler, EasycommParserStandard3, &custom_cb_invoked);
    // custom_cb_invoked == false
    // some_cb_invoked == false because VU is a standard 3 command but CBs are registered only for standard 2

    // suppress unused variable warnings
    (void)custom_cb_invoked;
    (void)some_cb_invoked;
}

Parse from stream: see full example

More examples: native-integration-test-program.cpp, unit tests

Checks

pio-run.yaml
pio-check.yaml
unit-tests.yaml
integration-tests-hamlib3x.yaml
integration-tests-hamlib4x.yaml
codeql-analysis.yml

hamlib-rotctl-easycomm-parser's People

Contributors

rubienr avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hamlib-rotctl-easycomm-parser's Issues

[FR] implement get `UM`/`DM` mode

Description
According to the command reference UM/DM without arguments shall respond with the current setting but the implementation is missing.

Solution

  • implement parser for UM/DM without arguments

[FR] implement get `UP`/`DN` frequency

Description
According to the command reference UP/DN without arguments shall respond with the current setting but the implementation is missing.

Solution

  • implement parser for UP/DN without arguments

[FR] update to PlatformIO 6.0

Description

  • do update the code to be compliant
    • with PlatformIO 6.0 + Unity (needs: platformio.ini update and implementation of further Unity transport, etc)
  • do code cleanup so that all commands and related methods are called
    • ...setCommandXXX... and ...getCommandXXX... when commands can be used as setter and getter
    • ...doCommandXXX... when commands are only used to trigger actions

[FR] implement get `UR`/`DR` radio

Description
According to the command reference UR/DR without arguments shall respond with the current setting but the implementation is missing.

Solution

  • implement parser for UR/DR without arguments

[BUG] update integration tests once https://github.com/Hamlib/Hamlib/issues/1006 is fixed

Description
In rotctl the Easycomm protocol (--model=204) defines a wrong callback easycomm_rot_move_velocity for the \move command.
See Hamlib/Hamlib#1006.

How to reproduce
Run the following integration tests:

def _test_easycomm2_rotctl_v4_move_up():

def _test_easycomm2_rotctl_v4_move_down():

def _test_easycomm2_rotctl_v4_move_left():

def _test_easycomm2_rotctl_v4_move_right():

def _test_easycomm3_rotctl_v4_move_up():

def _test_easycomm3_rotctl_v4_move_down():

def _test_easycomm3_rotctl_v4_move_left():

def _test_easycomm3_rotctl_v4_move_right():

Expected behavior
Once the bug Hamlib/Hamlib#1006 is fixed the listed tests have to be updated accordingly.

[BUG] problem using sscanf with platform ststm32

Description
Set time command fails to parse on ststm32 platform.

How to reproduce

  • pio test -e ststm32 -f easycomm2_ao_lo_op_ip_an_st_ve
test/easycomm2_ao_lo_op_ip_an_st_ve/test.cpp:254:test_parse_acquisition_of_signal	[PASSED]
test/easycomm2_ao_lo_op_ip_an_st_ve/test.cpp:255:test_parse_loss_of_signal	[PASSED]
test/easycomm2_ao_lo_op_ip_an_st_ve/test.cpp:256:test_parse_set_output_01	[PASSED]
test/easycomm2_ao_lo_op_ip_an_st_ve/test.cpp:257:test_parse_set_output_02	[PASSED]
test/easycomm2_ao_lo_op_ip_an_st_ve/test.cpp:258:test_parse_read_input_01	[PASSED]
test/easycomm2_ao_lo_op_ip_an_st_ve/test.cpp:259:test_parse_read_input_02	[PASSED]
test/easycomm2_ao_lo_op_ip_an_st_ve/test.cpp:260:test_parse_read_analogue_input_01	[PASSED]
test/easycomm2_ao_lo_op_ip_an_st_ve/test.cpp:261:test_parse_read_analogue_input_02	[PASSED]
test/easycomm2_ao_lo_op_ip_an_st_ve/test.cpp:53:test_parse_set_time_01:FAIL: failed to parse	[FAILED]
test/easycomm2_ao_lo_op_ip_an_st_ve/test.cpp:53:test_parse_set_time_02:FAIL: failed to parse	[FAILED]
test/easycomm2_ao_lo_op_ip_an_st_ve/test.cpp:53:test_parse_set_time_03:FAIL: failed to parse	[FAILED]
test/easycomm2_ao_lo_op_ip_an_st_ve/test.cpp:265:test_parse_request_version	[PASSED]

Expected behaviour
All tests green.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.