Coder Social home page Coder Social logo

baos's People

Contributors

robot300795 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

baos's Issues

c++ example to control group address

I am using knx usb module 322.

Any example how to control (for starting just on/off) by using this sdk.

I didn't find any examples or documentation for kdrive c/c++ api .

Thank you

Serial FT1.2 first write fails after reset/reboot

Baos SDK fails on the very first write attempt after baos chip/module has performed a reboot caused by ETS action.

Steps to reproduce:

  • Baos 83x starter kit connected via USB on PC (Linux host)

  • Configure Baos 83x via ETS, Datapoint ID=1, DPT=1(boolean)

  • Using following sample application to perform cyclic write action to datapoint:

//based on sample "BaosSerial.cpp"
#include <kdrive/baos/Baos.h>
#include <kdrive/connector/CallbackThread.h>
#include <kdrive/utility/Logger.h>
#include <kdrive/utility/LoggerFormatter.h>
#include <Poco/Exception.h>
#include <Poco/Format.h>
#include <iostream>

using namespace kdrive::baos;
using namespace kdrive::connector;
using namespace kdrive::utility;
using Poco::Exception;
using Poco::format;

CLASS_LOGGER("BaosSerial")

int main(int argc, char *argv[])
{
  // configure the logging channel
  INIT_ROOT_CONSOLE_LOGGER();
  Poco::Logger::root().setLevel("debug");
  Poco::Logger::get("kdrive.io.serial.SerialPort").setLevel("error");

  try {
    // connects the BAOS FT 1.2 Module
    FT12Connector::Ptr connector = std::make_shared<FT12Connector>();
    connector->open("/dev/ttyUSB0");

    // get the Serial Number
    BaosServerItems baosServerItems(connector);
    poco_information(LOGGER(),
        format("Serial Number: %s",
            LoggerFormatter::toHex(baosServerItems.getSerialNumber())));

    while (true) {
      BaosDatapoint dp(connector, 1);
      dp.setBoolean(true);
      sleep(3);
    }
  } catch (Exception &exception) {
    LOGGER().log(exception);
  }

  return EXIT_SUCCESS;
}
  • Run application. Cyclic write to datapoint is performed as expected
  • Perform a device reset via ETS
  • Depending on ft1.2 CI field byte (FCB/FCV) communication fails and exception is thrown. See following log:
13:02:33:344 [kdrive.ft12.FT12_Packetizer] ft1.2 rx: 68 0B 0B 68 F3 F0 C2 00 0A 00 01 00 0A 01 00 BB 16
13:02:33:344 [kdrive.ft12.FT12] Rx invalid FT1.2 variable frame
13:02:33:373 [kdrive.ft12.FT12_Packetizer] ft1.2 tx: E5
13:02:33:373 [kdrive.ft12.FT12_Packetizer] ft1.2 rx: 68 0B 0B 68 D3 F0 C2 00 0A 00 01 00 0A 01 01 9C 16
13:02:36:681 [kdrive.ft12.FT12_Packetizer] ft1.2 tx: 68 0C 0C 68 53 F0 06 00 01 00 01 00 01 03 01 01 51 16
13:02:36:705 [kdrive.ft12.FT12_Packetizer] ft1.2 rx: E5
13:02:41:706 [kdrive.connector.CallbackThread] Callback thread stop requested [id 2, QueueConnector Rx]
13:02:41:716 [kdrive.connector.CallbackThread] Callback thread stopped [id 2, name QueueConnector Rx]
13:02:41:719 [kdrive.connector.CallbackThread] Callback thread stop requested [id 1, AsyncConnectorNotificationHandler]
13:02:41:720 [kdrive.connector.CallbackThread] Callback thread stopped [id 1, name AsyncConnectorNotificationHandler]
13:02:41:720 [BaosSerial] Timeout

Reason of issue

Cause of the issue is a bug at FT12_Packetizer::readBytes function. Return type of FT12_Packetizer::readBytes is boolean instead of std::size_t. This leads to FT12_Packetizer::readFixedFrame failing to get the correct number of bytes read when Reset.Ind 0x10 0xC0 0xC0 0x16 was received due to reset.

//FIXME: Length is determined from bool returned by readBytes
std::size_t length = readBytes(ptr + 1, bufferSize - 1, FixedLengthFrame::Length - 1, shortTimeout) + 1;

Bugfix

Fix FT1.2_Packetizer like so:

FT12_Packetizer.h

  • Change return type from bool to std::size_t
std::size_t readBytes(char* buffer, std::size_t bufferSize, std::size_t bytesToRead, long timeout);

FT12_Packetizer.cpp

  • Change return type of FT12_Packetizer::readBytes from bool to std::size_t
  • Return length instead of boolean condition bytesToRead ? true : false at FT12_Packetizer::readBytes
std::size_t FT12_Packetizer::readBytes(char* buffer, std::size_t bufferSize, std::size_t bytesToRead, long timeout)
{
	BOOST_ASSERT(bytesToRead <= bufferSize && "Buffer Overflow");

	std::size_t length = 0;
	while ((length < bytesToRead) && serialPort_.poll(timeout))
	{
		const std::size_t n = serialPort_.read(buffer + length, bytesToRead - length);

		if (n > 0)
		{
			length += n;
		}
	}

	return length;
}
  • FT12_Packetizer::get: Change ternary condition to fit new return type of FT12_Packetizer::readBytes
//FT12_Packetizer::get
const std::size_t length = (readBytes(ptr, bufferSize, 1, timeout_) == 1) ? readFrame(buffer, bufferSize) : 0;

After the fix, the Reset.Ind appears in log and is handled correctly by resetting FCB/FCV:

13:07:16:224 [kdrive.ft12.FT12_Packetizer] ft1.2 rx: 10 C0 C0 16
13:07:16:736 [kdrive.ft12.FT12_Packetizer] ft1.2 tx: E5
13:07:16:736 [kdrive.ft12.FT12_Packetizer] ft1.2 rx: 68 0B 0B 68 F3 F0 C2 00 0A 00 01 00 0A 01 00 BB 16
13:07:16:752 [kdrive.ft12.FT12_Packetizer] ft1.2 tx: E5
13:07:16:752 [kdrive.ft12.FT12_Packetizer] ft1.2 rx: 68 0B 0B 68 D3 F0 C2 00 0A 00 01 00 0A 01 01 9C 16
13:07:17:254 [kdrive.ft12.FT12_Packetizer] ft1.2 tx: 68 0C 0C 68 73 F0 06 00 01 00 01 00 01 03 01 01 71 16
13:07:17:277 [kdrive.ft12.FT12_Packetizer] ft1.2 rx: E5
13:07:17:294 [kdrive.ft12.FT12_Packetizer] ft1.2 tx: E5
13:07:17:294 [kdrive.ft12.FT12_Packetizer] ft1.2 rx: 68 08 08 68 F3 F0 86 00 01 00 00 00 6A 16

How to debug "[BaosSerial] Timeout"

Hi,
I am trying to get my kBerry to work.
While I was (partially) successfull using knxd to program it, I still fail on many operations, such as using the sample_BaosSerial.

The output of sample_BaosSerial:
./sample_BaosSerial
12:21:56:628 [] Console Logger Started
12:22:01:686 [BaosSerial] Timeout

How can I debug this?
I followed the instructions on https://github.com/weinzierl-engineering/baos/blob/master/docs/Raspbian.adoc .

Any help would be appreciated
------------------------------------- additional information -------------------------------
uname -a:
"Linux openHABianDevice 5.4.72-v7+ #1356 SMP Thu Oct 22 13:56:54 BST 2020 armv7l GNU/Linux"

tail /boot/config.txt:
[all]
gpu_mem=16
enable_uart=1
dtoverlay=disable-bt

cannot execute samples

After following the compile description I get this error on the Raspberry Pi.

-bash: ./sample_BaosSerial: cannot execute: required file not found

boost configuration failed build error

I've tried to build baos on linux but i've stuck on this error.

/home/anand/Desktop/baos-18.2.0/kdrive/include/kdrive/utility/PropertyCollection.h:19:10: fatal error: boost/signals2.hpp: No such file or directory
 #include <boost/signals2.hpp>
          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.

i've downloaded boost_1_80_0.tar.gz and extracted it to the project dir.
and also tried to clone
https://github.com/boostorg/signals2.
but i've still got the error.

What is the folder structure for correct installation of this lib?.

Raspbian.adoc pi3-miniuart-bt

I think there is a typo in Raspbian.adoc
It should be sudo sh -c "echo dtoverlay=pi3-miniuart-bt >>/boot/config.txt"

Compile sample error "undefined reference to kdrive"

/home/henzycuong1/knxTest/main.cpp:32: error: undefined reference to kdrive::utility::LoggerFormatter::LoggerFormatter()' :-1: error: /home/henzycuong1/build-knxTest-Desktop_Qt_5_12_5_GCC_64bit-Debug/../knxTest/main.cpp:32: undefined reference to kdrive::utility::LoggerFormatter::initRootConsoleLogger()' :-1: error: /home/henzycuong1/build-knxTest-Desktop_Qt_5_12_5_GCC_64bit-Debug/../knxTest/main.cpp:37: undefined reference to kdrive::baos::BaosIpEnumerator::getDevices[abi:cxx11]() const' :-1: error: /home/henzycuong1/build-knxTest-Desktop_Qt_5_12_5_GCC_64bit-Debug/../knxTest/main.cpp:44: undefined reference to kdrive::baos::BaosIpEnumerator::getName(std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned char> const&) const' :-1: error: /home/henzycuong1/build-knxTest-Desktop_Qt_5_12_5_GCC_64bit-Debug/../knxTest/main.cpp:45: undefined reference to kdrive::baos::BaosIpEnumerator::getInterfaceAddress(std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned char> const&) const'

File: BaosIpEnumerator.cpp

Software: Qt 5.12.5

Sorry, my English's bad. How to fix the error? Do you want more information about this?

Some confusion

Hello. I've bought and used quite a few Weinzierl products in my projects. For this reason i thought that the Kberry was a great option. My plan was to get in touch with your reps at Light n Building.

Recently i had the need to be able to read data from an UART and send it on the KNX bus natively. I've used open source Arduino solutions in the past. But it seems to be very unreliable when used for long periods of time.

To get to the point. My programming skills are limited therefore i'd prefer Python. This readme comepletely skips the Python part it seems. Even though in the offciale SDK, you can find 3 Python samples. I'd like to run them on the Raspberry pi. What is the easiest way of running the actual code on the system.

Where can a compiled kdriveExpress.so be found ?
And where does it need to be placed ?

Buffer overrun while receiving 14 bytes payload (string value) using BAOSProtocol 1.2

The kdrive framework runs into an buffer overrun, while receiving events with 14 bytes payload (string values) using BAOSProtocol 1.2 (KNX IP BAOS 770).

Log output:
19:15:51:911 [kdrive.baos.ProtocolDecoder] Rx : IndicationFunctions::DatapointValueIndication
F0 C1 A4 01 A4 0E 5A 77 61 6E 67 73
19:15:51:911 [kdrive.baos.StreamConnector12] Error in rxImpl, BAOS Client exception: Invalid Service
19:15:51:911 [kdrive.baos.BaosEvent] BAOS Client exception: Buffer overrun while decoding Datapoint Value (buffer)
19:15:51:911 [kdrive.connector.CallbackThread] Callback thread terminated by unhandled Poco exception [id 2]: BAOS Client exception: Invalid Service
19:15:51:911 [BaosEventListener] BAOS Connector disconnected

The exception occurs in kdrive/src/baos/protocols/Protocol12.cpp line 301:

ServerItem value;
value.id = *ptr++;
const unsigned char stateLength = *ptr++;
value.serviceData = (stateLength << 4) & 0xF0;
value.length = stateLength & 0x0F;

if (static_cast<std::size_t>((ptr + value.length) - begin) > bufferSize)
{
	throw ClientException("Buffer overrun while decoding Datapoint Value (buffer)");
}

Analysis 1:
static_caststd::size_t((ptr + value.length) - begin) returns 16
bufferSize returns 8

Analysis 2:
Received packet (from log output above):
F0 C1 A4 01 A4 0E 5A 77 61 6E 67 73
-> F0 C1 A4 01 A4 0E (received 1 DatapointValue.Ind with ID 164 and 14 bytes payload length)
-> 5A 77 61 6E 67 73 (followed by 6 bytes payload instead of 14 bytes)

Countercheck:
Received packet with KnxBAOS DemoClient for protocol 1.x:
F0 C1 A4 01 A4 0E 5A 77 61 6E 67 73 62 65 74 72 69 65 62 20
-> F0 C1 A4 01 A4 0E (received 1 DatapointValue.Ind with ID 164 and 14 bytes payload length)
-> 5A 77 61 6E 67 73 62 65 74 72 69 65 62 20 (followed by 14 bytes payload)

Conclusion:
The buffer size per received datapoint is set to 8 bytes, which is too small to receive a datapoint packet with 16 bytes (1 bytes for DP ID + 1 byte for DP state/length + 14 bytes payload). Therefore the datapoint packet is not fully received, as it does not fit in the buffer.

Question:
How can the buffer size be increased?

how to get the programmed groupadresses in a kdrive datapoint?

Hi,
i am working with a kberry.
i have 3 programmed datapoints in a baos 830 in ETS:
one dpt1 with address 1/2/0
one dpt3 with address 1/2/4
and one dpt5 with address 1/2/3
I would like to read in a c++ programm the groupadresses programmed in each datapoint.
It is possible with the Baos c++ baos api?

thanks!

serial I/O error

Hi,
i'm using raspberry pi 3 b+ with kberry module. Following the user guide document but get the error below. Need help or advise...thanks.

14:02:08:274 [] Console Logger Started
14:02:08:297 [kdrive.connector.Connector] Open failed: I/O error: short write on serial port: 0 of 4 bytes
14:02:08:398 [BaosSerial] I/O error: short write on serial port: 0 of 4 bytes

compilation problem on Raspberry Pi 4

Hello,
I write this command in a Raspberry Pi 4:
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/raspbian-toolchain.cmake -DWZSDK_SAMPLES=1 -DWZSDK_STATIC=1 -G "Unix Makefiles" ../

But these errors have appeared:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /opt/toolchains/raspberrypi/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc
-- Check for working C compiler: /opt/toolchains/raspberrypi/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc -- broken
CMake Error at /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
  The C compiler

    "/opt/toolchains/raspberrypi/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/pi/baosSDK/baos/build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/make cmTC_fd10a/fast && /usr/bin/make -f CMakeFiles/cmTC_fd10a.dir/build.make CMakeFiles/cmTC_fd10a.dir/build
    make[1]: se entra en el directorio '/home/pi/baosSDK/baos/build/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_fd10a.dir/testCCompiler.c.o
    /opt/toolchains/raspberrypi/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc   -isystem /opt/toolchains/raspberrypi/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/include -fPIC    -o CMakeFiles/cmTC_fd10a.dir/testCCompiler.c.o   -c /home/pi/baosSDK/baos/build/CMakeFiles/CMakeTmp/testCCompiler.c
    /opt/toolchains/raspberrypi/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: 1: /opt/toolchains/raspberrypi/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: Syntax error: "(" unexpected
    make[1]: *** [CMakeFiles/cmTC_fd10a.dir/build.make:66: CMakeFiles/cmTC_fd10a.dir/testCCompiler.c.o] Error 2
    make[1]: se sale del directorio '/home/pi/baosSDK/baos/build/CMakeFiles/CMakeTmp'
    make: *** [Makefile:121: cmTC_fd10a/fast] Error 2
    

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:13 (project)


-- Configuring incomplete, errors occurred!
See also "/home/pi/baosSDK/baos/build/CMakeFiles/CMakeOutput.log".
See also "/home/pi/baosSDK/baos/build/CMakeFiles/CMakeError.log".

What I can do to solve it? Thank you

Timeout: PEI_Identify.Con missing

Hello,
please I have some trouble with baos compiled on Raspberry pi 3b+ and 830 Knx module.
This is the console output:
(1st attempt)
pi@raspberrypi:~ $ sudo ./baos/build_unix/bin/sample_BaosSerial
16:00:30:089 [] Console Logger Started
16:00:34:492 [kdrive.connector.CallbackThread] Callback thread timeout stop sync [id 2, name QueueConnector Rx]
16:00:39:493 [kdrive.connector.CallbackThread] Unable to join thread [id 2, name QueueConnector Rx]
16:00:39:493 [kdrive.connector.Connector] Open failed: Timeout: PEI_Identify.Con missing
16:00:39:594 [BaosSerial] Timeout: PEI_Identify.Con missing

(relaunch)
pi@raspberrypi:~ $ sudo ./baos/build_unix/bin/sample_BaosSerial
16:26:30:218 [] Console Logger Started
16:26:30:611 [FT12_Packetizer] Variable length frame checksum failed
16:26:32:731 [kdrive.connector.Connector] Open failed: Timeout: PEI_Identify.Con missing
16:26:32:831 [BaosSerial] Timeout: PEI_Identify.Con missing

(relaunch)
pi@raspberrypi:~ $ sudo ./baos/build_unix/bin/sample_BaosSerial
16:27:02:185 [] Console Logger Started
16:27:05:603 [kdrive.connector.Connector] Open failed: Timeout: PEI_Identify.Con missing
16:27:05:704 [BaosSerial] Timeout: PEI_Identify.Con missing

any hints will be appreciated
Marcello

Arduino compatibility

Hello,

Is there a way to integrate this SDK in Arduino code with an ESP32?

I have some Weinzierl BAOS Modules, but I dont know if I could use this SDK.

Thank you.

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.