Esempio n. 1
0
int camera_off(){
    go(0,OFFSET,OFFSET);
    stepper_off(sphere->st_rho);
    stepper_off(sphere->st_theta);
    stepper_off(sphere->st_phi);
    w_close();
}
Esempio n. 2
0
/**
* int doServ(uint16_t port)
*
* The is function is for server side socket connection 
* @param uint16_t port       port number for server connection
* @return integer
*
*
*****************************************************************************/
int doServ(uint16_t port){
	int listenfd,connfd;/*for socket file descriptor and connection descriptor*/
/*	struct linger s;
	 s.l_onoff = 1;
         s.l_linger = 10;*/
	
	pid_t childpid;//child process ID
	socklen_t clilen;
	char root[MAXLINE]="docs";
	struct sockaddr_in cliaddr,servaddr;//to store server details
	listenfd=socket(AF_INET,SOCK_STREAM,0);//connect to a socket
	bzero(&servaddr,sizeof(servaddr)); //set server address structure to 0
	servaddr.sin_family=AF_INET;//uses IPV4
	servaddr.sin_addr.s_addr=htonl(INADDR_ANY);//ready for listening for connections
	servaddr.sin_port=htons(port);/*set port to Book SERVER*/
	w_bind(listenfd,(struct sockaddr *)&servaddr,sizeof(servaddr)); //bind the port to the socket
	w_listen(listenfd,LISTENQ);//listen for connections
        Sigfunc *old=w_Sigaction(SIGCHLD ,sig_chld);
	while(1)
	{
		clilen=sizeof(cliaddr);
		if((connfd=accept(listenfd,(struct sockaddr *)&cliaddr,&clilen))<0){//if connect problem
		     if(errno == EINTR || errno == ECONNABORTED )//check for interrupts and aborts
			continue;
		 else
                	fprintf(stderr,"accept error:%s",strerror(errno));
			}	
	if((childpid= fork())==0){

		w_Sigaction(SIGCHLD ,old);
		w_close(listenfd);

//		setsockopt(connfd,SOL_SOCKET,SO_LINGER, &s, sizeof(s));

		doHTTPQuery(connfd,root);
 		w_close(connfd);
		exit(0);
		}
	 w_close(connfd);
		}				
	}
Esempio n. 3
0
int GetCDLabel(void){
    Window    wd;
    Field     fd;
    char      cdLabel[15];
    int       col=22, row=4, width=21, height=15;
    int       i,xkey;
    Control   lb;
    BYTE      Unit;
    strncpy(cdLabel,"    ",4);
    wd = w_open(col, row, width, height);
    w_umessage(wd,cdDriver);
    w_lmessage(wd,"ESC for New Driver");
    lb = c_add_listbox(wd," Drive  Label ",2,1,17,13,LISTBOX_SORT);
    for (Unit=0; Unit<=LastUnit; Unit++){
      (void)ReadPVD(Unit);
      if (CD=='I')
         strncpy(&cdLabel[4],iso->volLabel,11);
      else if (CD=='H')
         strncpy(&cdLabel[4],hsf->volLabel,11);
      else
         strncpy(&cdLabel[4],"Unknown Fmt",11);
      i=Unit;
      i/=10;
      cdLabel[1] = '0'+i;
      i=Unit;
      i%=10;
      cdLabel[2] = '0'+i;
      c_add_item(lb,cdLabel,-1,ENABLE);

   }
    xkey=c_dialog(wd);
    if (xkey == _ESC){
       w_close(wd);
       return -1;
    }
    else{
       Unit = c_read(lb,C_STATE);
       w_close(wd);
       return Unit;
    }
}
Esempio n. 4
0
void CacheCD(BYTE Unit){
   DWORD     i,n, volSize;
   int       handle;
   union REGS      regs;
   struct SREGS    sregs;
   Window    wd;
   int       col=5, row=4, width=68, height=1;

   (void)ReadPVD(Unit);
   if(CD==CD_ISO)
      volSize = iso->volSize;
   else if (CD==CD_HSF)
      volSize = hsf->volSize;
   else{
      printf("Unkown CD Format.  Can't cache it.\n");
      return;
   }

   for (i=0;i<sizeof dta;i++){dta[i]=0;}

   wd = w_open(col, row, width, height);
   w_umessage(wd,"Creating Cache File ");
   w_lmessage(wd,"Control Break to interrupt");
   handle = open(CacheName, O_BINARY|O_CREAT|O_WRONLY,S_IWRITE);
   SigFlag = 0;
   signal(SIGINT, SetSigFlag);
   i = 0;
   while (i < volSize){
     n = volSize - i;
   w_printf(wd,"Writing block %ld of %ld to %s.\n",i,volSize,CacheName);
     if (n>=30){
        (void)CDReadLong(Unit,30,i);
        (void)write(handle,pdta, 61440);
        i += 30;
        }
     else {
        (void)CDReadLong(Unit,n,i);
        (void)write(handle,pdta, n*2048);
        i += n;
        }
     if (SigFlag != 0){
       if (PauseContinue() == -1) break;
       else{
          SigFlag=0;
          signal(SIGINT, SetSigFlag);
       }
     }
   }

   w_close(wd);
   close (handle);
}
Esempio n. 5
0
int main (int argc, char **argv){
    Window    wd;
    int       col=5, row=1, width=68, height=1;
    union REGS      regs;
    struct SREGS    sregs;
    BYTE            Unit;
    int             rc;
    int             handle;

    width= strlen( copyrite);
    col = (80-width)/2;
    wd = w_open(col, row, width, height);
    w_print(wd,copyrite);

    if (argc > 1){
      if ((((argv[1][0] == '-') ||(argv[1][0] == '/'))&& (argv[1][1] == '?'))
         || (argv[1][0] == '?')){
            printf ("CACHCECD [DriverName] \n");
            goto done;
      }
      else cdDriver = argv[1];
    }
    iso = (struct ISO_CD *) pdta;
    hsf = (struct HSF_CD *) pdta;
    do {
       if (GetValidDriver() == -1){
          printf("No valid CD Driver.  Aborted.\n");
          goto done;
          }
       rc = GetCDLabel();
       }
    while (rc < 0);
    Unit = rc;
    if (GetCacheName() == -1){
          printf("User selected Quit.\n");
          goto done;
          }
    CanonCacheName(CacheName);
    handle = open(CacheName, O_BINARY);
    if (handle != -1){
       printf("%s already exists.\n",CacheName);
       printf("Delete file and re-run or re-run with different cache name.\n");
       close(handle);
       }
    else
       CacheCD(Unit);

 done:
    w_close(wd);
}
Esempio n. 6
0
int PauseContinue(void){
   int       xkey;
   Window    wd;
   int       col=15, row=10, width=48, height=1;
   wd = w_open(col, row, width, height);
   w_umessage(wd,"Control Break ");
   w_print(wd,"  Press ESC to Quit, any other key to continue.");
   xkey=k_getkey();
   w_close(wd);
   if (xkey==_ESC)
      return(-1);
   else
      return (0);

}
Esempio n. 7
0
int slave_read(){
    int i;
    verbose(L_SLVE,"%s:",slv_name);
    while((i=get_long(in))>=0){
        switch(i){
            case    ACT_NOP:break;
            case     ACT_ON:w_init();break;
            case    ACT_OFF:w_close();break;
            case  ACT_SLEEP:w_delayMicroseconds(get_long(in));break;
            case  ACT_WRITE:w_gpio_write(get_long(in),get_long(in));break;
            case   ACT_FSEL:w_gpio_fsel(get_long(in),get_long(in));break;
            case ACT_SETPUD:w_gpio_set_pud(get_long(in),get_long(in));break;
        }
    }
}
Esempio n. 8
0
int ValidateCacheName(Field fd, int lastkey){
    Window    wd;
    int       col=5, row=4, width=68, height=3;
    char tempCache[64];

   if (lastkey == _ESC) return FD_OK;
   f_getstring(fd,tempCache);
   CanonCacheName(tempCache);

   if (open(tempCache, O_BINARY|O_RDONLY, S_IWRITE)!=-1){
     close(tempCache);
     wd = w_open(col, row, width, height);
     w_umessage(wd,"Cache File Already Exists");
     w_lmessage(wd,"Press a key to Continue");
     w_print(wd,tempCache);
     k_getkey();
     w_close(wd);
     return FD_ERR;
     }
   else
     return FD_OK;
}
Esempio n. 9
0
int GetValidDriver(){
    Window    wd;
    Field     fd;
    char      *devName="________";
    int       col=5, row=4, width=15, height=4;
    int       field_col=3, field_row=1;
    int       xkey; /* don't declare lastkey if using f_validate  */

    wd = w_open(col, row, width, height);
    w_umessage(wd,"CD DRIVER");
    w_lmessage(wd,"ESC to Quit");
    fd = f_create("", devName);
    f_validate(fd,ValidateDriverName,DISABLE);
    f_startclear(fd,ENABLE);
    f_return(fd,ENABLE);
    f_setbuffer(fd,cdDriver);
    xkey = f_process(wd, field_col, field_row, fd);
    f_getstring(fd,cdDriver);
    f_free(fd);
    w_close(wd);
    if (xkey == _ESC) return -1;
    else return 0;
}
Esempio n. 10
0
int GetCacheName(){
    Window    wd;
    Field     fd;
    char      *fdData
          ="________________________________________________________________";
    int       col=5, row=4, width=68, height=3;
    int       field_col=1, field_row=1;
    int       xkey;

    wd = w_open(col, row, width, height);
    w_umessage(wd,"Cache File Name");
    w_lmessage(wd,"ESC to Quit");
    fd = f_create("", fdData);
    f_startclear(fd,ENABLE);
    f_return(fd,ENABLE);
    f_setbuffer(fd,CacheName);
    f_validate(fd,ValidateCacheName,DISABLE);
    xkey = f_process(wd, field_col, field_row, fd);
    f_getstring(fd,CacheName);
    f_free(fd);
    w_close(wd);
    if (xkey == _ESC) return -1;
    else return 0;
}