już nigdzie nie gubi przy ew. konwersji…
% uwaga!
% komp w pldoc!
% http://www.swi-prolog.org/packages/pldoc.html
% przemyslec, co da uzycie skladni wiki!
% czy porty dla sensorow sa abcd, czy 1,2,3,4?
nxt_port(a,['\x00\']).
% etc
nxt_sensor_type(no_sensor, ['\x00\']).
nxt_sensor_type(switch, ['\x01\']).
% etc
nxt_sensor_mode(rawmode, ['\x00\']).
nxt_sensor_mode(booleanmode, ['\x20\']).
% etc
nxt_cmd(setinputmode, ['\x00\','\x05\']).
nxt_cmd(messagewrite, ['\x00\','\x09\']).
%% nxt_prot(+Command, -NxtCmd, +Port, +Type, +Mode)
% return a nxt command with a given port, type, and mode (for setinputmode)
nxt_prot(setinputmode, NxtCmd, Port, Type, Mode) :-
nxt_cmd(setinputmode,Cmd),
nxt_port(Port, PortCmd),
nxt_sensor_type(Type, TypeCmd),
nxt_sensor_mode(Mode, ModeCmd),
flatten([Cmd, PortCmd,TypeCmd,ModeCmd],NxtCmd).
nxt_prot(messagewrite, NxtCmd, Inbox, Size,Data) :-
nxt_cmd(messagewrite,Cmd),
integer(Inbox), Inbox < 10, Inbox >= 0,
length(Data,L),
Size is L + 3,
Size < 60, % vide doc!
flatten([Cmd,Inbox,Size,Data],NxtCmd).
% tu nalezy jeszcze sprawdzic null termination vide dokuemntacja, ew dodac jak go nie ma!
% nxt_prot(setinputmode,C,a,switch,rawmode).
% nxt_prot(messagewrite,C,3,S,['a','l','a']).
% nxt_prot(messagewrite,C,3,_,['a','l','a']).
% aha, prosze przemyslec i potestowac, czy nie wystarczy powyzej pisac:
% nxt_prot(COSTAM, NxtCmd, Inbox, Size,Data) :-
% nxt_cmd(COSTAM,Cmd),
% na oko chyba tak!
:pl:miw:appendix_2-lego_mindstorms_nxt_direct_commands.pdf
: proszę dopisać URL gdzie za strony LEGO Pan to pobrał, czy to jest w BT dev guide?