Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with Python 3.5 write calling to_bytes(data) #10

Closed
cdkorzen opened this issue Jan 12, 2016 · 3 comments
Closed

Problems with Python 3.5 write calling to_bytes(data) #10

cdkorzen opened this issue Jan 12, 2016 · 3 comments

Comments

@cdkorzen
Copy link

I tried writing data to an opened serial port. The problem is the Python side tries to convert the data into bytes, and that conversion fails.

julia> versioninfo()
Julia Version 0.4.0
Commit 0ff703b* (2015-10-08 06:20 UTC)
Platform Info:
  System: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.3
Python 3.5.0 |Anaconda 2.4.0 (64-bit)| (default, Oct 20 2015, 07:26:33) [MSC v.1900 64 bit (AMD64)] on win32
julia> Pkg.status("PyCall")
 - PyCall                        1.2.0

julia> Pkg.status("SerialPorts")
 - SerialPorts                   0.0.7
julia> using SerialPorts

julia> s = SerialPort("COM9", 115200)
SerialPorts.SerialPort("COM9",115200,8,"N",1,nothing,false,false,false,PyObject
Serial<id=0x17539518, open=True>(port='COM9', baudrate=115200, bytesize=8, parit
y='N', stopbits=1, timeout=None, xonxoff=False, rtscts=False, dsrdtr=False))
julia> write(s,ASCIIString("G1X2"))
ERROR: PyError (:PyObject_Call) <class 'TypeError'>
TypeError("unicode strings are not supported, please encode to bytes: 'G1X2'",)
  File "C:\Users\Chris\Anaconda3\lib\site-packages\serial\serialwin32.py", line
301, in write
    data = to_bytes(data)
  File "C:\Users\Chris\Anaconda3\lib\site-packages\serial\serialutil.py", line 5
8, in to_bytes
    raise TypeError('unicode strings are not supported, please encode to bytes:
%r' % (seq,))

 [inlined code] from C:\Users\Chris\.julia\v0.4\PyCall\src\exception.jl:81
 in pycall at C:\Users\Chris\.julia\v0.4\PyCall\src\PyCall.jl:79
 in call at C:\Users\Chris\.julia\v0.4\PyCall\src\PyCall.jl:388
 in write at C:\Users\Chris\.julia\v0.4\SerialPorts\src\SerialPorts.jl:93

julia> write(s, UInt8(42))
ERROR: PyError (:PyObject_Call) <class 'TypeError'>
TypeError("'int' object is not iterable",)
  File "C:\Users\Chris\Anaconda3\lib\site-packages\serial\serialwin32.py", line
301, in write
    data = to_bytes(data)
  File "C:\Users\Chris\Anaconda3\lib\site-packages\serial\serialutil.py", line 6
1, in to_bytes
    for item in seq:

 [inlined code] from C:\Users\Chris\.julia\v0.4\PyCall\src\exception.jl:81
 in pycall at C:\Users\Chris\.julia\v0.4\PyCall\src\PyCall.jl:79
 in call at C:\Users\Chris\.julia\v0.4\PyCall\src\PyCall.jl:388
 in write at C:\Users\Chris\.julia\v0.4\SerialPorts\src\SerialPorts.jl:89
@sjkelly
Copy link
Member

sjkelly commented Jan 13, 2016

Hmm I haven't tested on 3.x in a while, so there could definitely be a regression. I'll work on it asap.

@sjkelly sjkelly changed the title Problems with Python write calling to_bytes(data) Problems with Python 3.5 write calling to_bytes(data) Jan 10, 2017
@DarioSarra
Copy link

Any update on this?

@sjkelly
Copy link
Member

sjkelly commented Mar 27, 2019

@DarioSarra I believe this should be fixed in v0.2.1.

@sjkelly sjkelly closed this as completed Apr 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants