How to use MATLAB to send signals to a port of an IP address?
The fact is that I have connected a robot car with PC by Wifi and I've decided that the signal FF000400FF
received by the robot will drive the car forward. I tested this by TCP&UDP tools and it was OK. So I think it should have been OK using MATLAB to send this signal, too.
my code is:
t = tcpip('192.168.1.1',2001);
fopen(t);
a=dec2hex(1095216922879); %FF000400FF(H)
fprintf(t,a)
but it doesn't work. I've been working on this for long but failed.
Open the TCP/IP Explorer app from either the Apps tab in the MATLAB toolstrip or the MATLAB command prompt. Click Configure TCP/IP Connection. Specify Address as the server address and Port as the server port to connect to the server.
Hardware connection functions define a connection to a CAN interface hardware that establishes a physical connection to a CAN bus. The CAN Transmit Workflow shows how to pack and transmit CAN messages with MATLAB®. You can also employ event-based message transmission; load and replay messages.
try this one:
fwrite(t, [255, 0, 4, 0, 255])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With