Skip to content

Commit

Permalink
add alternative constructor for initialized SerialPort
Browse files Browse the repository at this point in the history
  • Loading branch information
sjkelly committed Jan 10, 2017
1 parent c263445 commit c52f4d8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/SerialPorts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,9 @@ function in_dialout()
end

@doc """
Initialize a REPL. Calling conventions are identical to `SerialPort`
Initialize a REPL. Calling conventions are identical to `SerialPort`.
""" ->
function REPL(args...)
s = SerialPort(args...)
function REPL(s::SerialPort)
@async begin
while true
print(String(readavailable(s)))
Expand All @@ -157,10 +156,14 @@ function REPL(args...)
while true
print_with_color(:magenta, "\nserial> ")
c = readline()
!isspace(c) && write(s, c)
!isspace(c) && write(s, c) # Don't send newlines
end
end

function REPL(args...)
REPL(SerialPort(args...))
end

# Submodules

include("Arduino.jl")
Expand Down

0 comments on commit c52f4d8

Please sign in to comment.