SENA HD1100 User Manual
Page 35

Starter Kit and User Manual for the HelloDevice 1100
32
P24
G24
Hello Device Vcc
K1
DSP1a-DC24V
4
3
1
6
D1
1N4148
1
2
Q3
KTD1028
1
2
3
ISO19
PC817
1
2
4
3
LED?
LED RED
1
2
R2
330
R3
10K
OUT
OA
OB
Figure 6.8. Example of output interface hardware design with the HelloDevice
6.3 Sample Programs
6.3.1 Communication Using the Socket Program
The following C program source code shows an example implementing the Internet socket interface using the
Berkeley socket C API. This sends and receives the I/O control signals through the TCP port number 6001 of the
HelloDevice. The users can program an application for remote I/O control by modifying this sample code to
suite his application. The full source can be obtained in the “…\Source\C\iodemo.c” subdirectory of the
HelloDevice installation folder.
//---------------------
// Process I/O Monitor
//---------------------
void IOMonitor()
{
char
commandBuf, *ResponseBuf ;
int
commandLen, lenReceived ;
int
i ;
// Initialize TCP socket
TCPSocketInit() ;
// Make TCP command
commandBuf = IOGet ;
commandLen = 1 ;
// Send command to HelloDevice
err = sendto
(
sock,
&commandBuf,
commandLen,
0,