Sample communication application – Beijer Electronics SCOM Protocol EN User Manual
Page 128
Sample Communication Application
128
Beijer Electronics, MAEN975
Hello world... ;-)
*/
int
main(int argc,char *argv[],char *envp[])
{
int i;
char *pcEnd;
unsigned char aucSCOM[_SCOM_MAX_MSG_LEN];
int s;
int iso;
struct sockaddr_in sai;
int iBytesToSend;
int iBytesRead;
#ifdef _WIN32
WSADATA wsad;
#endif /* _WIN32 */
/*========*/
printf(_
"lscom +++ Lauer SCOM Sample Communication Application"_
"(c) Elektronik-Systeme Lauer GmbH & Co. KG"_
_);
if (argc<3)
{
printUsage("Too less arguments");
return -1;
}
if (argc>_SCOM_MAX_DAT_LEN+3)
{
printUsage("Too many arguments");
return -1;
}
for (i=0;i { switch (i) { /* Parameter 0: Full file name */ case 0: /* Not used. */ break; /* Parameter 1: Destination address */ case 1: aucSCOM[_SCOM_MSG_OFS_ADDR]=(unsigned char)strtoul(argv[i],&pcEnd,0); break; /* Parameter 2: Command */ case 2: strncpy((char*)&aucSCOM[_SCOM_MSG_OFS_CMD0],mystrupr(argv[i]),3); break; /* Parameter 3..n: Sub-commands/parameters */ default: aucSCOM[_SCOM_MSG_OFS_DATA+i-3]=(unsigned char)strtoul(argv[i],&pcEnd,0); } } i-=3;