From 666b20e8d2d95bfc3dab348b8fd3472ddd6846da Mon Sep 17 00:00:00 2001 From: Chandrashekhar Dhulipala Date: Wed, 1 Jun 2016 14:31:04 +0530 Subject: [PATCH 1/8] Update REQUIRE Added StringEncodings dependency --- REQUIRE | 1 + 1 file changed, 1 insertion(+) diff --git a/REQUIRE b/REQUIRE index acb0195..4599e24 100644 --- a/REQUIRE +++ b/REQUIRE @@ -2,3 +2,4 @@ julia 0.4 Compat Docile PyCall +StringEncodings From 0e9d304164c839c3ab4a1580a7ed8953bb84c347 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Dhulipala Date: Wed, 1 Jun 2016 14:43:57 +0530 Subject: [PATCH 2/8] Added write method to accept Unicode Strings --- src/SerialPorts.jl | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/SerialPorts.jl b/src/SerialPorts.jl index 5e00328..df7f56a 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() @@ -83,6 +83,31 @@ function Base.write(serialport::SerialPort, data::SerialString) serialport.python_ptr[:write](data) end +function Base.write(serialport::SerialPort, data::UTF8String) + bytes = encode(data,"UTF-8") + + if bytes[1] == 87 + if sizeof(bytes) == 3 serialport.python_ptr[:write](bytes) end + if sizeof(bytes) == 4 + if bytes[3] == 195 bytes[4] = bytes[4] + 64 end + three_bytes = [ bytes[1] , bytes[2] , bytes[4] ] + serialport.python_ptr[:write](three_bytes) + end + + elseif bytes[1] == 77 + if sizeof(bytes) == 3 || sizeof(bytes) == 4 serialport.python_ptr[:write](bytes) end + if sizeof(bytes) == 5 + if bytes[4] == 195 bytes[5] = bytes[5] + 64 end + four_bytes = [ bytes[1] , bytes[2] , bytes[3] , bytes[5] ] + serialport.python_ptr[:write](four_bytes) + end + + else + serialport.python_ptr[:write](bytes) + end + +end + function Base.read(ser::SerialPort, bytes::Integer) ser.python_ptr[:read](bytes) end From f385c8467d192bd1d08ea28070dac084857d6657 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Dhulipala Date: Tue, 14 Jun 2016 12:26:20 +0530 Subject: [PATCH 3/8] Update write function for Unicode strings --- src/SerialPorts.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/SerialPorts.jl b/src/SerialPorts.jl index df7f56a..5c40963 100644 --- a/src/SerialPorts.jl +++ b/src/SerialPorts.jl @@ -100,7 +100,14 @@ function Base.write(serialport::SerialPort, data::UTF8String) if bytes[4] == 195 bytes[5] = bytes[5] + 64 end four_bytes = [ bytes[1] , bytes[2] , bytes[3] , bytes[5] ] serialport.python_ptr[:write](four_bytes) - end + end + + elseif bytes[1] == 83 + if sizeof(bytes) == 4 serialport.python_ptr[:write](bytes) end + if sizeof(bytes) == 5 + four_bytes = [ bytes[1] , bytes[2] , bytes[3] , bytes[5] ] + serialport.python_ptr[:write](four_bytes) + end else serialport.python_ptr[:write](bytes) From 8103bb048ce1888e3978186306d89095f4aeabb5 Mon Sep 17 00:00:00 2001 From: Chandrashekhar Dhulipala Date: Mon, 20 Jun 2016 14:44:22 +0530 Subject: [PATCH 4/8] simplify write method (cherry picked from commit 4b7817ee4da836e80ebd7459b39e1dbf354fb71b) --- src/SerialPorts.jl | 49 +++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/src/SerialPorts.jl b/src/SerialPorts.jl index 5c40963..bf1ea35 100644 --- a/src/SerialPorts.jl +++ b/src/SerialPorts.jl @@ -84,35 +84,26 @@ function Base.write(serialport::SerialPort, data::SerialString) end function Base.write(serialport::SerialPort, data::UTF8String) - bytes = encode(data,"UTF-8") - - if bytes[1] == 87 - if sizeof(bytes) == 3 serialport.python_ptr[:write](bytes) end - if sizeof(bytes) == 4 - if bytes[3] == 195 bytes[4] = bytes[4] + 64 end - three_bytes = [ bytes[1] , bytes[2] , bytes[4] ] - serialport.python_ptr[:write](three_bytes) - end - - elseif bytes[1] == 77 - if sizeof(bytes) == 3 || sizeof(bytes) == 4 serialport.python_ptr[:write](bytes) end - if sizeof(bytes) == 5 - if bytes[4] == 195 bytes[5] = bytes[5] + 64 end - four_bytes = [ bytes[1] , bytes[2] , bytes[3] , bytes[5] ] - serialport.python_ptr[:write](four_bytes) - end - - elseif bytes[1] == 83 - if sizeof(bytes) == 4 serialport.python_ptr[:write](bytes) end - if sizeof(bytes) == 5 - four_bytes = [ bytes[1] , bytes[2] , bytes[3] , bytes[5] ] - serialport.python_ptr[:write](four_bytes) - end - - else - serialport.python_ptr[:write](bytes) - end - + 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) From 9c926751afa926a6862f531016cd0bdb4259a274 Mon Sep 17 00:00:00 2001 From: Steve Kelly Date: Thu, 12 Jan 2017 17:59:23 -0500 Subject: [PATCH 5/8] specify min compat version --- REQUIRE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/REQUIRE b/REQUIRE index 4599e24..cd38c6d 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,5 +1,5 @@ julia 0.4 -Compat +Compat 0.7.20 Docile PyCall StringEncodings From bff837f610c3db61064bce4c2f03860dae38d3ec Mon Sep 17 00:00:00 2001 From: Steve Kelly Date: Thu, 12 Jan 2017 18:01:31 -0500 Subject: [PATCH 6/8] fix permissions in travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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())' From 63fd7136f7a72c943d9e4a6238d0d8ee857a20ed Mon Sep 17 00:00:00 2001 From: Steve Kelly Date: Sun, 15 Jan 2017 16:14:11 -0500 Subject: [PATCH 7/8] remove redundant write function --- src/SerialPorts.jl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/SerialPorts.jl b/src/SerialPorts.jl index bf1ea35..06dc28b 100644 --- a/src/SerialPorts.jl +++ b/src/SerialPorts.jl @@ -79,10 +79,6 @@ 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) -end - function Base.write(serialport::SerialPort, data::UTF8String) bytes = encode(data,"UTF-8") if sizeof(bytes) == length(data) From 38d9fb9c91205df5e5f010abcbb1ef8c09178e15 Mon Sep 17 00:00:00 2001 From: Steve Kelly Date: Sun, 15 Jan 2017 16:14:32 -0500 Subject: [PATCH 8/8] tabs for spaces --- src/SerialPorts.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SerialPorts.jl b/src/SerialPorts.jl index 06dc28b..b589981 100644 --- a/src/SerialPorts.jl +++ b/src/SerialPorts.jl @@ -80,7 +80,7 @@ function Base.write(serialport::SerialPort, data::@compat UInt8) end function Base.write(serialport::SerialPort, data::UTF8String) - bytes = encode(data,"UTF-8") + bytes = encode(data,"UTF-8") if sizeof(bytes) == length(data) serialport.python_ptr[:write](bytes) else