Control interaction between FSP and fsp
Today, when I encountered a task at work, I changed the code for communications between matlab and FSP spectrometer to VC ++. At that time, I was surprised that matlab could write communication programs, matlab is really cool.
At first, I thought it was UDP communication. I wrote a subprogram and found that the analyzer was not a bird at all...
Use TCP instead. The code snippet is as follows:
If (soc = socket (AF_INET, SOCK_STREAM, 0) <= 0) {printf ("create socket failed \ n"); return-1;} addr. sin_family = AF_INET; addr. sin_addr.S_un.S_addr = inet_addr ("192.168.0.19"); // ipaddr of the analyzer. sin_port = htons (5025); // The port number connect (soc, (struct sockaddr *) & addr, sizeof (addr); send (soc, ": INIT: cont off \ n ", strlen (": INIT: cont off \ n ") +); //: INIT: cont off command is used to capture the display interface of the analyzer, that is, the display screen closesocket (soc) is paused );