weinzierl-engineering / baos

BAOS SDK - http://weinzierl-engineering.github.io/baos
MIT License
40 stars 18 forks source link

Some confusion #12

Closed Sypros closed 4 years ago

Sypros commented 4 years ago

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 ?

Sypros commented 4 years ago

Ok

So the kdriveExpress.so was my fault. It was available in "kdriveExpress-16.1.0-raspbian" Even though i had to respecify path and filename in the python script.

So then i started running the script. There seems to be a syntax error on function "on _error_callback" in all samples. print 'kdrive error {0} {1}'.format(hex(e), str.value) Is supposed to be :

print ('kdrive error {0} {1}'.format(hex(e), str.value)) Then i restarted the shell and this is the result. So now i'm stranded here.

>>> %Run kdrive_express_group_write_serial.py 22:11:23:379 [] Console Logger Started 22:11:23:388 [kdrive.connector.Connector] Open failed: I/O error: cannot open serial port /: Is a directory 22:11:23:388 [kdrive.express.error] I/O error: cannot open serial port /: Is a directory kdrive error 0x2 b'I/O error: cannot open serial port /: Is a directory' 22:11:23:489 [kdrive.express] U

weinzierl-engineering commented 4 years ago

It is not a syntax error. Those Python samples are Python2 and not Python3. Your problems are probably linked to this. If you want to use it with Python 3 a few things have to be adapted. One thing you have to be aware of is the different handling of strings in Python 3. The ctypes library which provides the interface to the kdriveExpress.so needs byte strings but python 3 default strings are unicode. So each time you call a function from the kdriveExpress library with a string as a parameter you have to encode it properly.

For example: kdrive.kdrive_ap_open_serial_ft12(ap, '/dev/ttyAMA0'.encode())

Sypros commented 4 years ago

Thank you very much. That was indeed the problem.

The sample script successfully did a write operation on the KNX BUS via the BAOS. It is now up to me to play with the SDK functions to achief my goal.

My respect for Weinzierl Engineering.