BAC0 icon indicating copy to clipboard operation
BAC0 copied to clipboard

How do I write a Bitstring Presentvalue?

Open Chris-Wang-bjc opened this issue 1 year ago • 8 comments

I can't write a Bitstring Presentvalue right now, the error info is: TypeError('invalid constructor datatype')

Chris-Wang-bjc avatar Aug 04 '22 08:08 Chris-Wang-bjc

If you dont mind me asking, what is a BitString or what is your use case? Strings over BACnet?

So it looks like in bacpypes objects.py there is such a thing.

Make sure your syntax is same as BACpypes...Maybe something like if I correctly - bitstringValue presentValue instead of Bitstring Presentvalue:

BAC0 read request:

read_vals = f'{address} bitstringValue {object_instance} presentValue'

What does your code look like?

bbartling avatar Aug 04 '22 18:08 bbartling

@bbartling Thanks for your reply. Sorry, I may not have explained my problem, it's write property service, not read property service. There is no problem with my code syntax, I can write the presentValue of other data types correctly, but the presentValue of "BitString" data type, when I use the same syntax to write a presentValue of this data type, it throws "TypeError('invalid constructor datatype')", so, can you please try to write a presentValue whose data type is BitString? Thanks!

Chris-Wang-bjc avatar Aug 05 '22 01:08 Chris-Wang-bjc

Can you show your code? I can see if I can get it to work on my end.

bbartling avatar Aug 05 '22 12:08 bbartling

Another thing you may want to do is find out if your device supports BitString data type.

bbartling avatar Aug 05 '22 15:08 bbartling

image Here is my code. I'm not sure the format of the "presentvalue" that I write correctly. I'm sure my device supports BitString data type, because I'm trying write it by VTS, it's successful. So please help me check it on your device, thanks!

Chris-Wang-bjc avatar Aug 08 '22 09:08 Chris-Wang-bjc

try getting rid of the curly brackets? {} ...I personally have never heard of bitString before with BACnet. What is your application again? HVAC in the field or security system? Or are you a BACnet developer on a test bench testing your real device with BAC0?

bbartling avatar Aug 08 '22 12:08 bbartling

BAC0 does not support Bitstring actually. To make it work, you could get inspiration from https://github.com/ChristianTremblay/BAC0/blob/master/BAC0/core/functions/Text.py

and build the request.

Bottom line is :

  • you create a complete request that will be sent to IOCB with deferred
  • in this request, the value will be "cast" to BitString in some way

A little trial and errors will probably be required.

I don't have any controller at hand support BitString....impossible for me to test for now.

ChristianTremblay avatar Aug 18 '22 12:08 ChristianTremblay

Thank you very much, I will take more try.

Chris-Wang-bjc avatar Aug 19 '22 02:08 Chris-Wang-bjc

This issue had no activity for a long period of time. If this issue is still required, please update the status or else, it will be closed. Please note that an issue can be reopened if required.

github-actions[bot] avatar Oct 18 '22 04:10 github-actions[bot]