コード例 #1
0
static void startc_drv_output(ErlDrvData handle, char *buff, int bufflen)
{
    startc_data* d = (startc_data*)handle;
 	CString strNodeName;
 	strNodeName = startc(atoi(buff));

	driver_output(d->port, (char*)(LPCTSTR)strNodeName, strNodeName.GetLength());
}
コード例 #2
0
ファイル: Dsock+serial+plot.c プロジェクト: rainfay/LedSign
int converttoFtoG3(char temp[6]){
	        int TempInC, TempInF;
		char stringtemp[50];
		int tempint;
	TempInC = atoi(temp);
	//syslog(LOG_WARNING, "temp is %d\n",TempInC);
        TempInF = TempInC * 1.8  + 32;
//	syslog(LOG_WARNING, "tempF is %d\n",TempInF);
                transbridgeon(mainfd);

	startc(mainfd,'Z','0');
    tempint=sprintf(stringtemp,"G3%d%c",TempInF,end);
     tempint=write(mainfd,stringtemp,tempint);
	        transbridgeoff(mainfd);
	        return 0;
}
コード例 #3
0
ファイル: Dsock+serial+plot.c プロジェクト: rainfay/LedSign
void IO_GO(int sig){
 syslog(LOG_ERR, "SIG IO SIG IO!!!!!!"); //Log it
mainfd = open_port();

        struct sockaddr_in clientName = { 0 };
        int BuffCount;  // Got Count 
	char Buff[1024]; //Buffer size 
        bzero(Buff,sizeof(Buff)); //Zero out the buffer
	int simpleChildSocket = 0;
        int clientNameLength = sizeof(clientName);
	int flag=0;
	char endL[3];
	char TempBuff[256];
	int TempCount;
	int returnstatus;
	bzero(endL,sizeof(endL));
	//transbridgeon(mainfd);
	sprintf(endL,"%c%c",end,0x82);

        simpleChildSocket = accept(simpleSocket,(struct sockaddr *)&clientName, &clientNameLength);

        if (simpleChildSocket == -1) {

            syslog(LOG_ERR, "Cannot accept connections!\n");
            close(simpleSocket);
            exit(1);

        }
        BuffCount=read(simpleChildSocket, Buff, 3);
	TempCount=sprintf(TempBuff,"%d",BuffCount);
        syslog(LOG_WARNING, "I read %d : %s",BuffCount,Buff);
	//trying a switch case to select the begining mode of the sign protocoll
	switch(Buff[0]){
	case 'A':// Sign Type, Sign Addr (last bit)
	startc(mainfd,Buff[1],Buff[2]);
        TempCount=sprintf(TempBuff,"CASE A");
	write(simpleChildSocket, TempBuff, strlen(TempBuff) );
	bzero(Buff,sizeof(Buff));

	break;
	case 'B': //simple mode 
	starttext(mainfd,'Z','0','A');
        TempCount=sprintf(TempBuff," CASE B");
        write(simpleChildSocket, TempBuff, strlen(TempBuff));
	bzero(Buff,sizeof(Buff));

	break;
	case 'C': //set 2 line mem
        TempCount=sprintf(TempBuff,"CASE C");
        write(simpleChildSocket, TempBuff, strlen(TempBuff));
    	syslog(LOG_ERR, "CASE C Buff1=%c",Buff[1]);
    	setmem(mainfd,Buff[1]);

        bzero(Buff,sizeof(Buff));

	flag =1;	// skip loop
	break;
	case 'D': //Single line set memory
        TempCount=sprintf(TempBuff,"CASE D");
        write(simpleChildSocket, TempBuff, strlen(TempBuff));

 syslog(LOG_ERR, "CASE D"); //Log it

	slsetmem(mainfd,Buff[1]);
	bzero(Buff,sizeof(Buff));
	 syslog(LOG_ERR, "End of Case D"); //Log it


	flag =1;
	break;
	case 'P': 
	plotit();
	flag=1;
	break;
	case 'X':
	 TempCount=sprintf(TempBuff,"CASE X");
        write(simpleChildSocket, TempBuff, strlen(TempBuff));
        bzero(Buff,sizeof(Buff));
	break;
	}
       while(flag != 1){

	BuffCount=read(simpleChildSocket, Buff, sizeof(Buff));
	if(DEBUG == 1)
	syslog(LOG_WARNING, "I read %d : %s",BuffCount,Buff);	
		if(endsearch(Buff)==1 )
		{
			flag=1;
		}
		if(BuffCount == 0){
			flag =1;
		}
        /* handle the new connection request  */
        /* write out our message to the client */

			write(mainfd,Buff,strlen(Buff));
			bzero(Buff,sizeof(Buff));
/* OLD CODE SNIPPIT
        write(simpleChildSocket, ACKMESSAGE, strlen(ACKMESSAGE));
        close(simpleChildSocket);
        transbridgeon(mainfd);
        write(mainfd,Buff,strlen(Buff));
        transbridgeoff(mainfd);

*/
	}
	//transbridgeoff(mainfd);
	        write(simpleChildSocket, ACKMESSAGE, strlen(ACKMESSAGE));

	close(simpleChildSocket);
	close(mainfd);
	flag = 0;
	usleep(250);


}
コード例 #4
0
ファイル: Dsock+serial+plot.c プロジェクト: rainfay/LedSign
int tempIO(void){
	close(mainfd);
	mainfd = open_port();
	int temp,count,rv;
	 int sockfd = 0;

	    int returnStatus = 0;
	    int i,index,JOSF ;
	    char buff[256] = "";
	    char buffer[256] = "";
	    char stringtemp[256] = "";
	    char JOS[4],JIN[4],HIN[4];
	char s[INET6_ADDRSTRLEN];

	    struct sockaddr_in simpleServer;
	    struct hostent *server;
	 struct addrinfo hints, *servinfo, *p;
	 memset(&hints, 0, sizeof hints);
	    hints.ai_family = AF_UNSPEC;
	    hints.ai_socktype = SOCK_STREAM;
	    if ((rv = getaddrinfo("xkun.endofnet.com", "5050", &hints, &servinfo)) != 0) {
	        syslog(LOG_ERR, "getaddrinfo: %s\n", gai_strerror(rv));
	        return 1;
	    }
		 /* create a streaming socket      */
	    for(p = servinfo; p != NULL; p = p->ai_next) {
	        if ((sockfd = socket(p->ai_family, p->ai_socktype,
	                p->ai_protocol)) == -1) {
	        	syslog(LOG_ERR, "client: socket");
	            continue;
	        }

	        if (connect(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
	            close(sockfd);
	            syslog(LOG_ERR, "client: connect");
	            continue;
	        }

	        break;
	    }
	    	    if (p == NULL) {
	    	    	syslog(LOG_ERR, "client: failed to connect\n");
	    	        return 2;
	    	    }

	    	    inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr),
	    	            s, sizeof s);
	    	    syslog(LOG_ERR, "client: connecting to %s\n", s);

	    	    freeaddrinfo(servinfo); // all done with this structure



	    	       temp=sprintf(stringtemp,"E"); //see DAE code for commands
	    	        temp=write(sockfd,stringtemp,temp); // normal shove out the door code

	    	        read(sockfd,stringtemp,9);
	    	        syslog(LOG_ERR, "%s",stringtemp);
	    	        index = 0;
	    	        for(i=0; i<3; i++){
	    	        	JOS[index] = stringtemp[i];
	    	        	index++;
	    	        }
	    	        index++;
	    	        JOS[index]= '\0';
	    	        JOSF = converttoF(JOS);
	    	        index = 0;

	    	        for(i=3; i<6; i++){
	    	        	JIN[index] = stringtemp[i];
	    	        	index++;
	    	        }
	    	        index++;
	    	        JIN[index]= '\0';
	    	        index = 0;

	    		close(sockfd);
	    		startc(mainfd,'Z','0');
	    		count=sprintf(stringtemp,"G4%s%c",JIN,etx);
	    		write(mainfd,stringtemp,count);
	    		count=sprintf(stringtemp,"%cG5%s%c",stx,JOS,etx);
	    		write(mainfd,stringtemp,count);
	    		count=sprintf(stringtemp,"%cG6%d%c%c",stx,JOSF,etx,end);
	    		write(mainfd,stringtemp,count);
	    		close(mainfd);
	    		return 0;
}