View Source cm17a (cm17a v0.3.2)
Link to this section Summary
Functions
Send a command to the X10 firecracker controller
Encode the CM17A command
Generate a representation of the state of the serial port for each bit in the encoded command
Perform actions in the list of instructions on a serial port
Link to this section Types
-type cm17a_byte() :: 0 | 32 | 136 | 152 | 128 | 145 | 132 | 148 | 32.
-type cm17a_cmd() :: on | off | bright | dim | all_off | all_on | lamps_off | lamps_on | pause.
-type cm17a_code() :: 65..80.
-type cm17a_data() :: <<_:40>>.
-type cm17a_device() :: 1..16.
-type cm17a_insn() :: {non_neg_integer(), non_neg_integer(), timeout()}.
-type fd() :: any().
Link to this section Functions
-spec command(iodata(), cm17a_code(), cm17a_device(), cm17a_cmd()) -> ok | {error, file:posix()}.
-spec encode(cm17a_code(), cm17a_device(), cm17a_cmd()) -> cm17a_data().
-spec init(fd()) -> {ok, non_neg_integer()} | {error, file:posix()}.
-spec insn(cm17a_data()) -> [cm17a_insn()].
Generate a representation of the state of the serial port for each bit in the encoded command
insn/1 calls into an NIF to retrieve constants for serctl:ioctl/3 so the result is not portable.-spec process(FD :: fd(), Insn :: [cm17a_insn()], Init :: fun((any()) -> {ok, non_neg_integer()} | {error, file:posix()}), Run :: fun((any(), [cm17a_insn()]) -> ok | {error, file:posix()}), Reset :: fun((any(), non_neg_integer()) -> ok | {error, file:posix()})) -> ok.
-spec reset(fd(), non_neg_integer()) -> ok | {error, file:posix()}.
-spec run(fd(), [cm17a_insn()]) -> ok | {error, file:posix()}.
-spec send(fd(), [cm17a_insn()]) -> ok | {error, file:posix()}.
Perform actions in the list of instructions on a serial port
{ok,FD} = serctl:open("/dev/ttyUSB0"),
cm17a:send(FD, cm17a:insn(cm17a:encode($A,1,on))).
Is equivalent to: cm17a:command("/dev/ttyUSB0", $A, 1, on).