Code Monkey home page Code Monkey logo

Comments (5)

PowerBroker2 avatar PowerBroker2 commented on May 18, 2024 1

Hey Jeremy!

Bools are 1 byte objects both in Arduino/C++ and Python, so they should be compatible automatically. Bools are also automatically supported in pySerialTransfer.

from pyserialtransfer.

jmdelahanty avatar jmdelahanty commented on May 18, 2024 1

You're the best! I'll close this for now. If I run into something weird when I'm putting it into the code I'll just comment here.

from pyserialtransfer.

jmdelahanty avatar jmdelahanty commented on May 18, 2024 1

This totally works by the way!

from pyserialtransfer.

jmdelahanty avatar jmdelahanty commented on May 18, 2024

To double check, this means I don't need to do any val_type_overrides if what's fed into the tx_buffer is type bool? See this line for where I'm doing it.

So I could just add this to the transfer:

metaData_size = link.tx_obj(arduino_metadata['lickContingency'], metaData_size)

lickContingency is a Boolean value (literally True or False)

from pyserialtransfer.

PowerBroker2 avatar PowerBroker2 commented on May 18, 2024

metaData_size = link.tx_obj(arduino_metadata['lickContingency'], metaData_size) should be fine because Python will automatically create a value type format for the transmission if the payload object is of a built-in Python type (i.e. bool):

tx_obj():

if type(val) == str:
val = val.encode()
format_str = '%ds' % len(val)
elif type(val) == dict:
val = json.dumps(val).encode()
format_str = '%ds' % len(val)
elif type(val) == float:
format_str = 'f'
elif type(val) == int:
format_str = 'i'
elif type(val) == bool:
format_str = '?'
elif type(val) == list:
for el in val:
start_pos = self.tx_obj(el, start_pos)
return start_pos

I'd say give it a shot and see if it works

from pyserialtransfer.

Related Issues (20)

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.