diff --git a/.travis.yml b/.travis.yml index f5c6748..bfdd772 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ julia: - nightly notifications: email: false -sudo: true +sudo: false script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - julia -e 'Pkg.clone(pwd())' diff --git a/REQUIRE b/REQUIRE index acb0195..cd38c6d 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,4 +1,5 @@ julia 0.4 -Compat +Compat 0.7.20 Docile PyCall +StringEncodings diff --git a/src/SerialPorts.jl b/src/SerialPorts.jl index 5e00328..b589981 100644 --- a/src/SerialPorts.jl +++ b/src/SerialPorts.jl @@ -5,7 +5,7 @@ module SerialPorts export SerialPort, SerialException, setDTR, list_serialports, check_serial_access -using Compat, PyCall +using Compat, PyCall, StringEncodings VERSION < v"0.4-" && using Docile const PySerial = PyCall.PyNULL() @@ -79,8 +79,27 @@ function Base.write(serialport::SerialPort, data::@compat UInt8) serialport.python_ptr[:write](data) end -function Base.write(serialport::SerialPort, data::SerialString) - serialport.python_ptr[:write](data) +function Base.write(serialport::SerialPort, data::UTF8String) + bytes = encode(data,"UTF-8") + if sizeof(bytes) == length(data) + serialport.python_ptr[:write](bytes) + else + i = 1 + a = Array(Int64,1) + while i <= sizeof(data) + if sizeof(string(data[i:i])) == 2 + if bytes[i] == 195 bytes[i+1] = bytes[i+1]+64 end + push!(a,i+1) + i = i+2 + else + push!(a,i) + i = i+1 + end + end + a = a[2:end] + bytes = bytes[a] + serialport.python_ptr[:write](bytes) + end end function Base.read(ser::SerialPort, bytes::Integer)