icinterface.fopen cannot bind

11 views (last 30 days)
Nick
Nick on 7 Mar 2014
Answered: Nick on 12 Mar 2014
I want to test a UDP module on a fpga board which should send data to a machine running Matlab through a ethernet cable.
I wrote the following script and test it between two machine running matlab, it works. In short, the script opens a udp object and print to screen each data it receives.
However, when I plug the ethernet cable to the machine and the board, running the script I got an error using icinterface.fopen: "it cannot bind" ( I presume it cannot assign the port or the ip address).
Assuming the worst scenario in which the udp module on the board does not work, I do not see why matlab should not be able to create a udp "listener". Udp do not require any syncronization or reply.
Any idea on what exaclty icinterface.fopen does? Why it cannot associate the port/address?
Here's the main script
ip_listener = '192.168.0.3'; % IP current machine
port_listener = hex2dec('6af0'); % port current machine
ip_source = '192.168.0.1'; % IP board
port_source =hex2dec('6aef'); % port board
nBytes = 5;
udp_listener = udp(ip_source, port_source, ...
'LocalPort', port_listener,'LocalHost', ip_listener);
udp_listener.BytesAvailableFcnCount = nBytes;
udp_listener.DatagramTerminateMode = 'off';
udp_listener.BytesAvailableFcnMode = 'byte';
udp_listener.BytesAvailableFcn = {'showBytes', nBytes};
fopen(udp_listener)
udp_listener.RecordDetail = 'compact';
udp_listener.RecordMode = 'append';
udp_listener.RecordName = [folder '\buffer_bytes.bin'];
record(udp_listener,'on') % save
% to close
% record(udp_listener,'off'); fclose(udp_listener)
which also requires this function
function showBytes(obj, event, n)
transpose(fread(obj,n))

Accepted Answer

Nick
Nick on 12 Mar 2014
fopen requires the ethernet port to be physically connected via cable with a POWER ON machine. Doing so, the code runs.

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!