How can I use Matlab TCPIP from the instrument control box to read data from a RS232 device server? (solved)

3 次查看(过去 30 天)
I'm not very experienced with TCPIP, so sorry if I am asking some stupid questions.
I have RS232 devices: e.g.: balances and other measurement instruments. The devices are connected to a RS232 device server (Lantronix). Using telnet (windows or any other client), communication works just fine, so the device server and the instruments are configured correctly e.g.: "telnet [IP Adress] [Port number]" from the command line "&e" command + Enter -> the measurement device sends back the measured values e.g: "4.162899383e-002 9.946371737e-001 :E,8F"
Using Matlab TCPIP from the instrument control box I tried the following code:
t=tcpip('P Adress',Port number)
set(t, 'InputBufferSize', 30000);
fopen(t)
fwrite(t,'&e')
while (get(t, 'BytesAvailable') > 0)
t.BytesAvailable
DataReceived = fscanf(t)
end
I dont get any error messages, but I also dont get any read back from the measurement device. There is nothing in the Input Buffer. The RS232 device server also does not register any bytes sent from the device, only those sent to the device. This might be some character set issue, since the command "&e" results in 4 bytes sent to the device and the matlab TCPIP only results in 2 bytes sent. Or maybe there is some other fundamental problem.
Does anyone have experience with this kind of issues and can help?

采纳的回答

Patrick
Patrick 2014-2-3
In found the answer, it was merely a syntax problem (/r,/n were missing).

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Test and Measurement 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by