Skip to content

Commit

Permalink
Issue warnings when the wrong DIO direction is set
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschumacher authored Feb 28, 2024
1 parent 06d16d0 commit b1906e2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/client/julia/src/SlowIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,12 @@ julia> DIO!(rp, DIO7_P, true)
true
```
"""
DIO!(rp::RedPitaya, pin, val) = query(rp, scpiCommand(DIO!, pin, val), scpiReturn(DIO!))
function DIO!(rp::RedPitaya, pin, val)
if DIODirection(rp, pin) == DIO_IN
@warn "The pin $pin is currently set as input. The value is applied anyways!"
end
return query(rp, scpiCommand(DIO!, pin, val), scpiReturn(DIO!))
end
scpiCommand(::typeof(DIO!), pin::DIOPins, val::Bool) = string("RP:DIO:", DIOPinToCommand(pin), " ", (val ? "ON" : "OFF"))
scpiReturn(::typeof(DIO!)) = Bool

Expand All @@ -168,7 +173,12 @@ julia>DIO(rp, DIO7_P)
true
```
"""
DIO(rp::RedPitaya, pin) = parseReturn(DIO, query(rp, scpiCommand(DIO, pin), scpiReturn(DIO)))
function DIO(rp::RedPitaya, pin)
if DIODirection(rp, pin) == DIO_OUT
@warn "The pin $pin is currently set as output. The value is read anyways but might be wrong!"
end
return parseReturn(DIO, query(rp, scpiCommand(DIO, pin), scpiReturn(DIO)))
end
scpiCommand(::typeof(DIO), pin) = string("RP:DIO:", DIOPinToCommand(pin), "?")
scpiReturn(::typeof(DIO)) = String
parseReturn(::typeof(DIO), ret) = occursin("ON", ret)
parseReturn(::typeof(DIO), ret) = occursin("ON", ret)

0 comments on commit b1906e2

Please sign in to comment.