|
Re: serial communication with hex strings
Posted:
Jan 29, 2009 12:15 PM
|
|
"Ken " <robinson@kuchera.com> wrote in message news:glsl90$gni$1@fred.mathworks.com... > Im trying to output a HEX string to a camera to makes it turn a filter on. > The command is '8101040102FF'. I've made a small m.file to do it. When i > run the m.file the filter doesnt turn on. > Im not sure if the HEX string is being output ftom the m.file to the com > port because nothing happens. > > code > > s=serial('COM1'); > set(s,'BaudRate', 9600); > set(s,'DataBits', 8); > set(s,'StopBits', 1); > fopen(s); > Str=('8101040102FF'); > sprintf('%s %X','8101040102FF') > fclose(s);
It looks like you already have the hex string. The only thing missing is FWRITE.
s=serial('COM1'); set(s,'BaudRate', 9600); set(s,'DataBits', 8); set(s,'StopBits', 1); fopen(s); Str=('8101040102FF'); fwrite(s,Str); fclose(s);
|
|