Rank: 33222 based on 0 downloads (last 30 days) and 0 file submitted
photo

Wei Ren

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Comments and Ratings by Wei Ren View all
Updated File Comments Rating
16 Nov 2009 TCP/IP Communications in Matlab Sends/receives TCP packets using Matlab's Java interface. Now handles matrices and cell arrays, etc. Author: Kevin Bartlett

Kevin: I just wanted to make sure that you didn't misunderstood what i said last. 0xB4 is 180 in decimal. I was getting -74 until I corrected what Edwin pointed out.

15 Nov 2009 TCP/IP Communications in Matlab Sends/receives TCP packets using Matlab's Java interface. Now handles matrices and cell arrays, etc. Author: Kevin Bartlett

so using mssg(i) = read( jTcpObj.dataInputStream ) actually solved the problem of why 0xB4 was becoming -74. (Thanks Edwin)

So this is what i do sending hex data
mssg = sscanf(' 02 04 05 B4 01 01 04 02','%x');
jTcpObj.dataOutputStream.write(mssg);
jTcpObj.dataOutputStream.flush;

jTcpObj.dataOutputStream.writeBytes(mssg) works as well and both would work without using the flush class too.

on the receiving end
convert the mssg to hex using dec2hex(mssg)

13 Nov 2009 TCP/IP Communications in Matlab Sends/receives TCP packets using Matlab's Java interface. Now handles matrices and cell arrays, etc. Author: Kevin Bartlett

I forgot to note that even though it's sent correctly through wireshark, im still unable to read it correctly yet on matlab.
any ideas on how 0xB4 becomes -74?

13 Nov 2009 TCP/IP Communications in Matlab Sends/receives TCP packets using Matlab's Java interface. Now handles matrices and cell arrays, etc. Author: Kevin Bartlett

so according to wireshark
mssg = sscanf(' 02 04 05 B4 01 01 04 02','%x');
using either
jTcpObj.dataOutputStream.writeBytes(char(mssg));
or
jTcpObj.dataOutputStream.write(mssg);
show as 02 04 05 B4 01 01 04 02 sent correctly. which is what I want.

also have you tried
data_reader = DataReader(d_input_stream);
message = data_reader.readBuffer(bytes_available);
Rodney had that new in his 2nd update of his syntax.
I tried adding that to your script but couldnt get it to work right.

09 Nov 2009 TCP/IP Communications in Matlab Sends/receives TCP packets using Matlab's Java interface. Now handles matrices and cell arrays, etc. Author: Kevin Bartlett

The thing is that I need my server to communicate to an application that will need it in HEX. so :(

Contact us