Skip to content

String type problem in python 3 #8

@martinks

Description

@martinks

With initializing the pump in python 3.6 it seems there's a problem with the string types.

chain = pumpy.Chain('/dev/tty.usbserial-FTDCM5J7')
pump = pumpy.PHD2000(chain)

gives

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-17-f7ad48ff2e5c> in <module>()
      1 chain = pumpy.Chain('/dev/tty.usbserial-FTDCM5J7')
----> 2 pump = pumpy.PHD2000(chain)
      3 pump.stop()

/Users/kleinschaarsbergmh/miniconda3/lib/python3.6/site-packages/pumpy.py in __init__(self, chain, address, name)
     61         the pump is connected and working."""
     62         try:
---> 63             self.write('VER')
     64             resp = self.read(17)
     65 

/Users/kleinschaarsbergmh/miniconda3/lib/python3.6/site-packages/pumpy.py in write(self, command)
     81 
     82     def write(self,command):
---> 83         self.serialcon.write(self.address + command + '\r')
     84 
     85     def read(self,bytes=5):

/Users/kleinschaarsbergmh/miniconda3/lib/python3.6/site-packages/serial/serialposix.py in write(self, data)
    530         if not self.is_open:
    531             raise portNotOpenError
--> 532         d = to_bytes(data)
    533         tx_len = length = len(d)
    534         timeout = Timeout(self._write_timeout)

/Users/kleinschaarsbergmh/miniconda3/lib/python3.6/site-packages/serial/serialutil.py in to_bytes(seq)
     61         return seq.tobytes()
     62     elif isinstance(seq, unicode):
---> 63         raise TypeError('unicode strings are not supported, please encode to bytes: {!r}'.format(seq))
     64     else:
     65         # handle list of integers and bytes (one or more items) for Python 2 and 3

TypeError: unicode strings are not supported, please encode to bytes: '00VER\r'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions