0 | module Bindings.RtlSdr.EEProm
2 | import Bindings.RtlSdr.Device
3 | import Bindings.RtlSdr.Error
4 | import Bindings.RtlSdr.Raw.EEProm
5 | import Bindings.RtlSdr.Raw.Support
14 | decodeRetError : Int -> RTLSDR_ERROR
15 | decodeRetError e = case e of
16 | -
1 => RtlSdrHandleInvalid
17 | -
2 => RtlSdrEEPromSizeExceeded
18 | -
3 => RtlSdrEEPromNotFound
27 | readEEProm : Ptr RtlSdrHandle -> Int -> Int -> IO (Either RTLSDR_ERROR Buffer)
28 | readEEProm h o l = do
29 | Just buf <- newBuffer l
30 | | Nothing => io_pure $
Left RtlSdrError
31 | r <- fromPrim $
read_eeprom h buf o l
32 | io_pure $
if r < 0 then Left (decodeRetError r) else Right buf
41 | writeEEProm : Ptr RtlSdrHandle -> Buffer -> Int -> IO (Either RTLSDR_ERROR ())
42 | writeEEProm h b o = do
44 | r <- fromPrim $
write_eeprom h b o len
45 | io_pure $
if r < 0 then Left (decodeRetError r) else Right ()