From: Naimi Naimi on
want to send hex commands to calibrate a projector through matlab tcp/ip interface,the connection is established but dont know how to transmit data and in which format...


t=tcpip('192.168.0.10',4172)%ip and port of projector
fopen(t)

for example

to turn on:
02H 00H 00H 00H 0FH 02H

now how do i send it
From: Walter Roberson on
Naimi Naimi wrote:
> want to send hex commands to calibrate a projector through matlab tcp/ip
> interface,the connection is established but dont know how to transmit
> data and in which format...

> t=tcpip('192.168.0.10',4172)%ip and port of projector
> fopen(t)

> for example

> to turn on:
> 02H 00H 00H 00H 0FH 02H

> now how do i send it

Do you mean that you would send the character '0' then the character '2'
then the character 'H' ? Or is the 'H' just for our reading? Would the
space ' ' get sent after that, or would you send '020000000F02' all as
one stream? Of you need to send the ascii representation of the nibbles,
consider using fprintf(t, '%X', data)

Or do you mean that you need to send the byte whose hex representation
is 02 then the 0 byte thrice, then the byte whose hex representation is
0F, then another of the 02's? Which would leave you sending
char([2, 0, 0, 0, 15, 2]) ?

If you have a list of hex values and you need to create the
corresponding ascii character positions, then
char(hex2bin(['02';'00';'00';'00';'0F';'02']))

Note: if you choose to use fwrite() instead of fprintf(), then be quite
careful about your data types, and remember that numbers such as 2 are
stored as double precision by default. If you have such numbers, then
either fwrite(t, TheData, 'double=>uint8') or else
fwrite(t, char(TheData), '*char')
From: Naimi Naimi on
thanx,i will just check it out
and also 'H' character is just for reading and format i gave was given the projector's manual.
From: Naimi Naimi on
statement:

fwrite(t,char(data),'char')

working perfectly
 | 
Pages: 1
Prev: DAQ Toolbox
Next: optimization