Skip to content

Commit 64f2ab9

Browse files
authored
Merge pull request #31 from yakeworld/master
Update SerialPorts.jl -> getindex changes
2 parents 4790544 + a94a1ec commit 64f2ab9

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

src/SerialPorts.jl

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,66 +29,67 @@ function __init__()
2929
end
3030

3131
function SerialPort(port, baudrate::Real)
32-
py_ptr = PySerial[:Serial](port, baudrate)
32+
py_ptr = PySerial.Serial(port, baudrate)
3333
SerialPort(port,
3434
baudrate,
35-
py_ptr[:bytesize],
36-
py_ptr[:parity],
37-
py_ptr[:stopbits],
38-
py_ptr[:timeout],
39-
py_ptr[:xonxoff],
40-
py_ptr[:rtscts],
41-
py_ptr[:dsrdtr], py_ptr)
35+
py_ptr.bytesize,
36+
py_ptr.parity,
37+
py_ptr.stopbits,
38+
py_ptr.timeout,
39+
py_ptr.xonxoff,
40+
py_ptr.rtscts,
41+
py_ptr.dsrdtr,
42+
py_ptr)
4243
end
4344

4445
function Base.isopen(serialport::SerialPort)
45-
serialport.python_ptr[:isOpen]()
46+
serialport.python_ptr.isOpen()
4647
end
4748

4849
function Base.open(serialport::SerialPort)
49-
!isopen(serialport) && serialport.python_ptr[:open]()
50+
!isopen(serialport) && serialport.python_ptr.open()
5051
return serialport
5152
end
5253

5354
function Base.close(serialport::SerialPort)
54-
serialport.python_ptr[:close]()
55+
serialport.python_ptr.close()
5556
return serialport
5657
end
5758

5859
function Base.flush(ser::SerialPort)
59-
ser.python_ptr[:flush]()
60+
ser.python_ptr.flush()
6061
end
6162

6263
function Base.isreadable(ser::SerialPort)
63-
ser.python_ptr[:readable]()
64+
ser.python_ptr.readable()
6465
end
6566

6667
function Base.iswritable(ser::SerialPort)
67-
ser.python_ptr[:writable]()
68+
ser.python_ptr.writable()
6869
end
6970

7071
function Base.write(serialport::SerialPort, data::UInt8)
71-
serialport.python_ptr[:write](Base.CodeUnits(String([data])))
72+
serialport.python_ptr.write(Base.CodeUnits(String([data])))
7273
end
7374

7475
function Base.write(serialport::SerialPort, data::String)
75-
serialport.python_ptr[:write](Base.CodeUnits(data))
76+
serialport.python_ptr.write(Base.CodeUnits(data))
7677
end
7778

7879
function Base.read(ser::SerialPort, bytes::Integer)
79-
ser.python_ptr[:read](bytes)
80+
ser.python_ptr.read(bytes)
8081
end
8182

8283
function Base.bytesavailable(ser::SerialPort)
83-
ser.python_ptr[:inWaiting]()
84+
ser.python_ptr.inWaiting()
8485
end
8586

8687
function Base.readavailable(ser::SerialPort)
8788
read(ser, bytesavailable(ser))
8889
end
8990

9091
function setDTR(ser::SerialPort, val)
91-
ser.python_ptr[:setDTR](val)
92+
ser.python_ptr.setDTR(val)
9293
end
9394

9495
function _valid_linux_port(x)
@@ -112,7 +113,7 @@ function list_serialports()
112113
return [string("/dev/", port) for port in ports]
113114
end
114115
@static if Sys.iswindows()
115-
[i[1] for i in collect(PySerialListPorts[:comports]())]
116+
[get(i,0) for i in collect(PySerialListPorts.comports())]
116117
end
117118
end
118119

0 commit comments

Comments
 (0)