Beispiel #1
0
/**
 * \brief Periodic process which will send any data currently loaded for transmission
 */
void CCOM_Task(void)
{
	uint32_t u32GetAddr;
	uint8_t *pu8Data;
	uint8_t i;

	if(!rbuf_empty(&ccomBuf))
	{
		rbuf_get(&ccomBuf,&u32GetAddr);

		pu8Data = (uint8_t *)u32GetAddr;
		//if(USB_isReady()){ USB.write(pu8Data,MAX_FRAME_SIZE); }
		usb_rawhid_send(pu8Data, MAX_FRAME_SIZE);

		//for(i=0;i<MAX_FRAME_SIZE;i++){ printf("%02x,",*pu8Data++); } printf("\n\r");
	}
	//else{ printf("No Data...\n\r"); }
}
Beispiel #2
0
int	main(int ac, char **av)
{
  int	fd_listen;
  int	fd_client;
  int	ret;
  rbuf	buf;

  DEBUG_ASCII_IN;
  if (ac < 2)
    usage(av[0]);
  printf ("[+] New tcp server on port %d\n", atoi(av[1]));
  if ((fd_listen = libnet_create_tcp_server(atoi(av[1]))) < 0)
    {
      printf("[-] Error\n");
      RETURN (-1);
    }
  printf("[+] Server is listening...\n");
  libnet_select_reset();
  libnet_select_add_fd(fd_listen);
  libnet_select_settimeout(0, 0);
  fd_client = -1;
  while (42)
    {
      if ((ret = libnet_select()))
	{
	  if (libnet_select_isset(fd_client))
	    {
	      buf = libnet_rbufget(fd_client);
	      printf("rbufget: %s\n", rbuf_get(buf));
	    }
	  if (libnet_select_isset(fd_listen))
	    {
	      printf("[+] New client\n");
	      fd_client = libnet_accept(fd_listen);
	      libnet_select_add_fd(fd_client);
	    }
	  printf("[+] libnet_select = %d\n", ret);
	}
    }
  RETURN (0);
}
Beispiel #3
0
void sem_server()
{
    Sem_request request;
    Semaphore* sem;
    int tid;
    int status;

    status = RegisterAs( SEMAPHORE_SERVER_NAME );
    assert( status == REGISTER_AS_SUCCESS );

    while( 1 ) {
        status = Receive( &tid, ( char* )&request, sizeof( request ) );
        assert( status == sizeof( request ) );

        sem = request.sem;

        switch( request.type ) {
        case SEM_RELEASE:
            sem->count += 1;
            status = Reply( tid, ( char* )&status, sizeof( status ) );
            assert( status == SYSCALL_SUCCESS );
            break;
        case SEM_AC_ALL:
            if( sem->count > 0 ) {
                sem->count = 1;
            }
        // Fall through
        case SEM_ACQUIRE:
            status = rbuf_put( &sem->wait_queue, ( uchar* )&tid );
            assert( status == ERR_NONE );
            break;
        }

        while( sem->count > 0 && ! rbuf_empty( &sem->wait_queue ) ) {
            sem->count -= 1;
            rbuf_get( &sem->wait_queue, ( uchar* )&tid );
            status = Reply( tid, ( char* )&status, sizeof( status ) );
            assert( status == SYSCALL_SUCCESS );
        }
    }
}