2 implementing java applet – SENA HD1300 User Manual
Page 34
![background image](/manuals/292691/34/background.png)
Starter Kit and User Manual for the HelloDevice 1300
34
//---------------------
// Process Serial data send
//---------------------
void SerialSend()
{
char
commandBuf[512]="" ;
int
commandLen ;
int
err ;
// Re-Initialize TCP socket
TCPSocketInit() ;
// Read serial data
// : just ASCII string excluding control characters...
// : Max size is limited to 512 bytes in this demo....
printf("\nEnter serial data:") ;
scanf("%s", commandBuf) ;
// Calc serial data length
commandLen = strlen(commandBuf) ;
// Send command to the HelloDevice
err = sendto
(
sock,
&commandBuf,
commandLen,
0,
(struct sockaddr*)&clientAddr,
sizeof(clientAddr)
) ;
if (err == -1 )
{
perror("\nsend error\n");
exit (1);
}
}
6.2.2 Implementing Java applet
Program source for terminal applet is located in “the HelloDevice Install folder\Src\SerialDemo\java” folder.
The source code is from public domain free source, “telnet java applet”. We modified the code so that it may
work with the HelloDevice. Further information on “telnet java applet” can be found in the folder of
“1300_telnet_documentation” of the HelloDevice install CDROM.