|
"SAGAR " <sagargkoli@yahoo.com> wrote in message
news:hmqkm1$h7q$1@fred.mathworks.com...
> "Trent Jarvi" <tjarvi@mathworks.com> wrote in message
> <hlv7n0$f2a$1@fred.mathworks.com>...
>>
>> "SAGAR " <sagargkoli@yahoo.com> wrote in message
>> news:hlucte$n99$1@fred.mathworks.com...
>> > I am working on a project in which I need to send data from serial port
>> > of one PC to serial port of other PC in real time , the PCs are in the
>> > same LAN, We will give data to server PC from micro-controller and
>> > client PC will give the same data to micro-controller connected to its
>> > serial port
>> > I have tried in both simulink and m file but it was not completely
>> > possible Pease help me I am student and not a professional so i know
>> > very little about MATLAB
>> >
>>
>> Could you share the MATLAB code that you are trying? Perhaps we can
>> identify a problem.
>
> to Send
>
> %Data flow From PC with IP 172.16.20.134 to PC with IP 172.16.20.32
> %On 172.16.20.134
> a = serial('COM1');
> fopen(a);
> u = tcpip('172.16.20.32', 9091, 'LocalPort', 9090 );
> fopen(u);
> for i = 0:1:10
> b = fgetl(a);
> fwrite(u,b);
> end
> fclose(a);
> fclose(u);
>
> clear u;
> u = instrfindall;
> clear a;
> a = instrfindall;
> clear
>
> To Receive
>
> %Data flow From PC with IP 172.16.20.134 to PC with IP 172.16.20.32 %on
> 172.16.20.32
> a = serial('COM1');
> fopen(a);
> u = tcpip('172.16.20.134', 9090, 'LocalPort', 9091 );
> fopen(u);
> for i = 0:1:10
> b = fgetl(u);
> fwrite(a,b);
> end
> fclose(a);
> fclose(u);
>
> clear u;
> u = instrfindall;
> clear a;
> a = instrfindall;
> clear
>
Thanks for sharing the code.
The code appears to be from a UDP example. With TCPIP, you need a server
socket on one side. MATLAB does not provide server sockets at this time.
You can replace TCPIP with UDP above or look around MATLAB Central File
Exchange for TCPIP server socket options.
|