diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..2ac1d690 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,42 @@ +name: Test + +# Run this job on all pushes and pull requests +# as well as tags with a semantic version +on: + push: + branches: + - '*' + pull_request: {} + +jobs: + + # Runs lib tests on all supported node versions and OSes + build-and-test: + if: contains(github.event.head_commit.message, '[skip ci]') == false + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + + steps: + - uses: actions/checkout@v1 + + - name: Install automake (macos) + if: startsWith(runner.OS, 'macOS') + run: brew install automake + + - name: Build + run: ./build.sh + + - name: Build tests + run: cd test && make + + - name: Test Success Frames + run: cd test && ./generate-xml.sh test-frames + + - name: Test Error Frames + run: cd test && ./generate-xml.sh error-frames || true + + - name: Test Unsupported Frames + run: cd test && ./generate-xml.sh unsupported-frames || true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 70b00795..00000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: c - -compiler: - - gcc - - clang - -os: - - linux - - osx - -script: - - ./build.sh - - cd test && make && ./generate-xml.sh test-frames - - cd test && make && ./generate-xml.sh test/error-frames || true - - cd test && make && ./generate-xml.sh test/unsupported-frames || true diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 60b5fa66..8479d063 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -1924,6 +1924,42 @@ mbus_send_request_frame(mbus_handle * handle, int address) return retval; } +//------------------------------------------------------------------------------ +// send a request packet to from master to slave +//------------------------------------------------------------------------------ +int +mbus_send_request_frame_fcb(mbus_handle * handle, int address) +{ + int retval = 0; + mbus_frame *frame; + + if (mbus_is_primary_address(address) == 0) + { + MBUS_ERROR("%s: invalid address %d\n", __PRETTY_FUNCTION__, address); + return -1; + } + + frame = mbus_frame_new(MBUS_FRAME_TYPE_SHORT); + + if (frame == NULL) + { + MBUS_ERROR("%s: failed to allocate mbus frame.\n", __PRETTY_FUNCTION__); + return -1; + } + + frame->control = MBUS_CONTROL_MASK_REQ_UD2 | MBUS_CONTROL_MASK_DIR_M2S | MBUS_CONTROL_MASK_FCB; + frame->address = address; + + if (mbus_send_frame(handle, frame) == -1) + { + MBUS_ERROR("%s: failed to send mbus frame.\n", __PRETTY_FUNCTION__); + retval = -1; + } + + mbus_frame_free(frame); + return retval; +} + //------------------------------------------------------------------------------ // send a user data packet from master to slave //------------------------------------------------------------------------------ diff --git a/mbus/mbus-protocol-aux.h b/mbus/mbus-protocol-aux.h index 4dacef4c..143c7eee 100755 --- a/mbus/mbus-protocol-aux.h +++ b/mbus/mbus-protocol-aux.h @@ -97,7 +97,7 @@ typedef struct _mbus_handle { void (*recv_event) (unsigned char src_type, const char *buff, size_t len); void (*send_event) (unsigned char src_type, const char *buff, size_t len); void (*scan_progress) (struct _mbus_handle *handle, const char *mask); - void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); + void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); void *auxdata; } mbus_handle; @@ -293,7 +293,8 @@ int mbus_send_switch_baudrate_frame(mbus_handle * handle, int address, long baud * * @return Zero when successful. */ -int mbus_send_request_frame(mbus_handle * handle, int address); + int mbus_send_request_frame(mbus_handle * handle, int address); + int mbus_send_request_frame_fcb(mbus_handle * handle, int address); /** * Sends user data frame (SND_UD) to given slave using "unified" handle