Esempio n. 1
0
void recoder::add_enc_packet(const uint8_t *data, const uint16_t len)
{
    size_t tmp_rank;

    guard g(m_lock);

    /* don't add packets when we have enough, and try to stop encoder
     * from sending more packets
     */
    if (this->is_complete()) {
        send_ack_packet();
        return;
    }

    if (curr_state() == STATE_DONE)
        return;

    CHECK_EQ(len, this->payload_size()) << "Recoder " << m_coder
                                        << ": Encoded data is too short:"
                                        << len << " < " << this->payload_size();

    /* keep track of changes in rank */
    tmp_rank = this->rank();

    this->decode(const_cast<uint8_t *>(data));

    /* check if rank improved */
    if (this->rank() == tmp_rank)
        inc("non-innovative recoded packets");

    update_timestamp();

    if (this->last_symbol_is_systematic()) {
        inc("systematic packets added");
        send_systematic_packet(data, len);
        m_budget--;
    } else {
        inc("encoded packets added");
    }

    /* signal state machine if generation is complete */
    if (this->is_complete()) {
        send_ack_packet();
        dispatch_event(EVENT_COMPLETE);
    } else {
        dispatch_event(EVENT_RX);
    }

    VLOG(LOG_PKT) << "Recoder " << m_coder << ": Added encoded packet";
}
Esempio n. 2
0
static uint8_t input_packet(struct net_buf *buf)
{
	uint8_t ret = 0;
	bool duplicate;

	if (handle_ack_packet(buf)) {
		return 0;
	}

	if (NETSTACK_FRAMER.parse(buf) < 0) {
		PRINTF("simpledc: parsing failed msg len %u\n",
		       packetbuf_datalen(buf));
		return 0;
	}

	duplicate = check_duplicate(buf);

	if (send_ack_packet(buf, &ret)) {
		return ret;
	}

	if (duplicate) {
		return 0;
	}

	return NETSTACK_MAC.input(buf);
}
Esempio n. 3
0
int FDL_McuResetNormal (PACKET_T *packet, void *arg)
{
    int i;
    //BOOT_ENTRY boot_entry = (BOOT_ENTRY) 0x40000000; /* Start of internal RAM */
#if 0

    /* Copy NBL to internal RAM */
    if (NAND_SUCCESS != nand_read_NBL ( (void *) boot_entry))
    {
        send_ack_packet (BSL_REP_OPERATION_FAILED);
        return 0;
    }

#endif
    FDL_SendAckPacket (BSL_REP_ACK);

    /* Wait until all characters are sent out. */
    for (i=0; i<0x0A000; i++)
    {
        /* Do nothing */;
    }
    FDL_ResetMcuClock();

    ResetMCU();

    /* We should not go here */
    return 0;
}
Esempio n. 4
0
void decoder::add_enc_packet(const uint8_t *data, const uint16_t len)
{
    size_t rank, symbol_index, msecs;
    bool systematic;
    size_t size = this->payload_size();

    guard g(m_lock);

    if (this->is_complete()) {
        inc("redundant received");
        if (++m_red_pkt_count % FLAGS_ack_interval == 0)
            send_ack_packet();
        return;
    }

    CHECK_EQ(len, size) << "Decoder " << m_coder
                        << ": Invalid length:" << len << " != " << size;

    rank = this->rank();
    this->decode(const_cast<uint8_t *>(data));
    m_enc_pkt_count++;

    if (this->rank() == rank) {
        VLOG(LOG_PKT) << "Decoder " << m_coder << ": Added non-innovative";
        inc("non-innovative received");
        update_timestamp();
        update_packet_timestamp();
        return;
    }

    systematic = this->last_symbol_is_systematic();
    symbol_index = this->last_symbol_index();

    if (this->is_complete()) {
        dispatch_event(EVENT_COMPLETE);
        return;
    }

    if (this->is_partial_complete())
        send_partial_decoded_packets(this->rank());

    if (systematic) {
        inc("systematic received");
        VLOG(LOG_PKT) << "Decoder " << m_coder << ": Added systematic ("
                      << symbol_index << ")";
        send_decoded_packet(symbol_index);
    } else {
        VLOG(LOG_PKT) << "Decoder " << m_coder << ": Added encoded";
        inc("encoded received");
    }

    update_timestamp();
    update_packet_timestamp();
}
Esempio n. 5
0
void decoder::send_decoded_packets()
{
    double ack_budget = source_budget(1, 254, 254, m_e3);

    VLOG(LOG_GEN) << "Decoder " << m_coder << ": Send decoded packets";
    inc("generations decoded");

    guard g(m_lock);
    for (; ack_budget > 0; ack_budget--)
        send_ack_packet();

    send_partial_decoded_packets(this->symbols());
    dispatch_event(EVENT_ACKED);
}
Esempio n. 6
0
int Job_status( int *sock, char *input )
{
	char *s, *t, *name, *hash_key;
	int displayformat, status_lines = 0, i, n;
	struct line_list l, listv;
	struct line_list done_list;
	char error[SMALLBUFFER], buffer[16];
	int db, dbflag;
	
	FILE *READSTATUSFILE;//JY1120
	char readbuffer[SMALLBUFFER];//JY1120
	char *str_index;//JY1120

#if !defined(JYWENG20031104status)
	if( input && *input ) ++input;//JY1114
	if(get_queue_name(input))
	{
		printf("QueueName is not LPRServer\n");
		send_ack_packet(sock, ACK_FAIL);//JY1120
		return(0);
	}
	else
		printf("QueueName is LPRServer\n");

	int prnstatus=1;
	char buffertosend[LARGEBUFFER];
	int fdPRNPARorUSB=0;/*JYWENG20031104*/
	if((check_par_usb_prn())== 1)
		fdPRNPARorUSB=open("/dev/usb/lp0",O_RDWR);
	else
		fdPRNPARorUSB=open("/dev/lp0",O_RDWR);

	if(fdPRNPARorUSB == 0)
	{
		printf("file descriptor not created\n");
		send_ack_packet(sock, ACK_FAIL);//JY1120
		return(0);	
	}
//	ioctl(fdPRNPARorUSB, 0x060b, &prnstatus);
//	if(prnstatus == 0)
//JY1120
	if((READSTATUSFILE=fopen("/var/state/printstatus.txt", "r")) == NULL)
	{
		printf("open /var/state/printstatus.txt failed!\n");
		send_ack_packet(sock, ACK_FAIL);//JY1120
		return(0);		
	}
	while( fgets(readbuffer, SMALLBUFFER, READSTATUSFILE) != NULL)
	{
		if((str_index = strstr(readbuffer, "PRINTER_STATUS=\"")))
		{
			str_index += 16;//moving to status
			strncpy(printerstatus, str_index, strlen(str_index) - 2 );	
		}
	}
//JY1120	

	SNPRINTF(buffertosend, sizeof(buffertosend))"Status: %s\n", printerstatus);
//	else
//		SNPRINTF(buffertosend, sizeof(buffertosend))"Status: Off line\n");
//	if( Write_fd_str( *sock, buffertosend ) < 0 ) cleanup(0);
	if( write( *sock, buffertosend, strlen(buffertosend) ) < 0 ) cleanup(0);
	exit(0);//JY1120
	
#endif


#ifdef REMOVE
	Init_line_list(&l);
	Init_line_list(&listv);
	Init_line_list(&done_list);
	db = Debug;
	dbflag = DbgFlag;

	Name = "Job_status";

	/* get the format */
	if( (s = safestrchr(input, '\n' )) ) *s = 0;
	displayformat = *input++;

	/*
	 * if we get a short/long request from these hosts,
	 * reverse the sense of question
	 */
	if( Reverse_lpq_status_DYN
		&& (displayformat == REQ_DSHORT || displayformat==REQ_DLONG)  ){
		Free_line_list(&l);
		Split(&l,Reverse_lpq_status_DYN,File_sep,0,0,0,0,0,0);
		if( Match_ipaddr_value( &l, &RemoteHost_IP ) == 0 ){
			DEBUGF(DLPQ1)("Job_status: reversing status sense");
			if( displayformat == REQ_DSHORT ){
				displayformat = REQ_DLONG;
			} else {
				displayformat = REQ_DSHORT;
			}
		}
		Free_line_list(&l);
	}
	/*
	 * we have a list of hosts with format of the form:
	 *  Key=list; Key=list;...
	 *  key is s for short, l for long
	 */
	DEBUGF(DLPQ1)("Job_status: Force_lpq_status_DYN '%s'", Force_lpq_status_DYN);
	if( Force_lpq_status_DYN ){
		Free_line_list(&listv);
		Split(&listv,Force_lpq_status_DYN,";",0,0,0,0,0,0);
		for(i = 0; i < listv.count; ++i ){
			s = listv.list[i];
			if( (t = safestrpbrk(s,File_sep)) ) *t++ = 0;
			Free_line_list(&l);
			Split(&l,t,Value_sep,0,0,0,0,0,0);
			DEBUGF(DLPQ1)("Job_status: Force_lpq_status '%s'='%s'", s,t);
			if( Match_ipaddr_value( &l, &RemoteHost_IP ) == 0 ){
				DEBUGF(DLPQ1)("Job_status: forcing status '%s'", s);
				if( safestrcasecmp(s,"s") == 0 ){
					displayformat = REQ_DSHORT;
				} else if( safestrcasecmp(s,"l") == 0 ){
					displayformat = REQ_DLONG;
				}
				status_lines = Short_status_length_DYN;
				break;
			}
		}
		Free_line_list(&l);
		Free_line_list(&listv);
	}

	/*
	 * check for short status to be returned
	 */

	if( Return_short_status_DYN && displayformat == REQ_DLONG ){
		Free_line_list(&l);
		Split(&l,Return_short_status_DYN,File_sep,0,0,0,0,0,0);
		if( Match_ipaddr_value( &l, &RemoteHost_IP ) == 0 ){
			status_lines = Short_status_length_DYN;
			DEBUGF(DLPQ1)("Job_status: truncating status to %d",
				status_lines);
		}
		Free_line_list(&l);
	}

	DEBUGF(DLPQ1)("Job_status: doing '%s'", input );
	Free_line_list(&l);
	Split(&l,input,Whitespace,0,0,0,0,0,0);
	if( l.count == 0 ){
		SNPRINTF( error, sizeof(error)) "zero length command line");
		goto error;
	}
Esempio n. 7
0
int Receive_job( int *sock, char *input )
{
	char line[SMALLBUFFER];		/* line buffer for input */
	char error[SMALLBUFFER];	/* line buffer for input */
	char buffer[SMALLBUFFER];	/* line buffer for input */
	int errlen = sizeof(error);
	char *tempfile;				/* name of temp file */
	double file_len;			/* length of file */
	double read_len;			/* amount to read from sock */
	double jobsize = 0;			/* size of job */
	int ack = 0;				/* ack to send */
	int status = 0;				/* status of the last command */
	double len;					/* length of last read */
	char *s, *filename;			/* name of control or data file */
	int temp_fd = -1;				/* used for file opening and locking */
	int filetype;				/* type of file - control or data */
	int fd;						/* for log file */
	int hold_fd = -1;				/* hold file */
	int db, dbf, rlen;
	int fifo_fd = -1;			/* fifo lock file */
	struct line_list files, info, l;
	struct job job;
	struct stat statb;

#ifdef REMOVE
#ifdef WINDOW_1//JYWeng
//aaaaaa=fopen("/tmp/pp", "a");
//fprintf(aaaaaa, "lpd_rcvjobs.c\n");
//fclose(aaaaaa);
#endif
#ifdef JYDEBUG//JYWeng
aaaaaa=fopen("/tmp/qqqqq", "a");
fprintf(aaaaaa, "Receive_job: check point 1\n");
fclose(aaaaaa);
#endif
#endif
	Init_line_list(&l);
	Init_line_list(&files);
	Init_line_list(&info);
	Init_job(&job);

	Name = "RECV";

	if( input && *input ) ++input;
	Clean_meta(input);
	Split(&info,input,Whitespace,0,0,0,0,0,0);

//printf("Receive_job!\n");//JY1107
/*JY1113: test QueueName*/
	if(get_queue_name(input))
	{
		//printf("QueueName is not LPRServer\n");
		send_ack_packet(sock, ACK_FAIL);//JY1120
		return(0);
	}
	//else printf("QueueName is LPRServer\n");
/**/

#ifdef ORIGINAL_DEBUG//JY@1020
	DEBUGFC(DRECV1)Dump_line_list("Receive_job: input", &info );
#endif
	if( info.count != 1 ){
		SNPRINTF( error, errlen) _("bad command line") );
		goto error;
	}
void SDRAM_Init(uint32 clk)
{
    SDRAM_CFG_INFO_T *pCfg = NULL;
 #if !defined (NAND_FDL_SC6800D)   
 	volatile unsigned long i,emcs_ctl;
	uint32 ctl0_val;
 #endif
    //Call Userdef_before_sdram_init()
    Userdef_before_sdram_init();
    //Get SDRAM_cfg
    pCfg = SDRAM_GetCfg();

#if defined (NAND_FDL_SC6800D)
	SDRAM_Clk_Dly_Cfg(clk,(pCfg->clk_dly & 0xFFFF),((pCfg->clk_dly & 0xFFFF0000) >> 16));

	*(volatile uint32 *)EXT_MEM_DCFG0 &= ~(DCFG0_AUTOREF_EN);

	*(volatile uint32 *)EXT_MEM_CFG0 |= BIT_15;

	SDRAM_GenMemCtlCfg();

	SDRAM_DMemCtlCfg(clk,pCfg);
	
	SDRAM_Device_Init(pCfg);

	*(volatile uint32 *)EXT_MEM_DCFG1 |= BIT_15;

	*(volatile uint32 *)EXT_MEM_DCFG0 &= ~(BIT_3);

	*(volatile uint32 *)EXT_MEM_DCFG0 |= BIT_23;
#elif defined (NAND_FDL_SC8800H)



	REG32(EXT_MEM_DCFG0) &= ~(DCFG0_AUTOREF_EN);    //Disable auto refresh

	SDRAM_GenMemCtlCfg(pCfg);
	
	//SDRAM_Auto_DllCtlCfg();							//automatically config the sdram

	SDRAM_DMemCtlCfg(clk,pCfg);

	SDRAM_Device_Init(pCfg);
	

    REG32(EXT_MEM_DCFG2) |= DCFG2_REF_CNT_RST;


    REG32(EXT_MEM_DCFG0) |=  (DCFG0_AUTOREF_EN);    //Enable auto refresh	


#else
    //Check SDRAM configuration
    if(NULL == pCfg)
    {
        send_ack_packet(BSL_ILLEGAL_SDRAM);
        return;
    }
    if((pCfg->cas_latency!=0x2) && (pCfg->cas_latency!=0x3))
    {
        send_ack_packet(BSL_WRONG_SDRAM_PARAMETER);
        return;
    }
    if(pCfg->sdram_size > 0x3)
    {
        send_ack_packet(BSL_WRONG_SDRAM_PARAMETER);
        return;
    }
    if(SDRAM_EXT_INVALID!=pCfg->ext_mode_val)
    {
        if(pCfg->ext_mode_val>0x3fff)
        {
           send_ack_packet(BSL_WRONG_SDRAM_PARAMETER);
           return;
        }   
    }
#if defined(NAND_FDL_SC6600R)
    *(volatile uint32 *)(0x8b000050) = 0;
    *(volatile uint32 *)(0x8b000054) = 0;
    for(i=0;i<100;i++);
#endif    
    //Set clock delay
    *(volatile uint32 *)CLK_DLY = pCfg->clk_dly;
    /*Initialize the SDRAM*/    
    //Refresh time = a
    //Precharge time = a
    //Active to read/write time = 1
    //Write recovery time = 2
    //CAS Latency time = pCfg->cas_latency & 0x3
    //burst length = 0x11
    //the mapping of SDRAM address is bank address,row address, col address.
    //the size of SDRAM is pCfg->sdram_size & 0x3
    ctl0_val = 0x800591aa | (pCfg->cas_latency<<13) | (pCfg->sdram_size<<19);
    *(volatile uint32 *)EXTMEMCTL0=ctl0_val;       //0x8019f1a5  //0x8015d162
    *(volatile uint32 *)EXTMEMINI = 0x00d24018;
    //Wait initialization finish
    emcs_ctl = *(volatile uint32 *)(0x20000024);
    while((emcs_ctl & 0x00000002) != 0x00000002)
    {
    	emcs_ctl = *(volatile uint32 *)(0x20000024);
    }    
    //Load Extend mode regiter if needed
    if(SDRAM_EXT_INVALID!=pCfg->ext_mode_val)
    {
       *(volatile uint32 *)EXTMEMINI = pCfg->ext_mode_val|(0x5<<22);       
	   //Wait initialization finish
	   emcs_ctl = *(volatile uint32 *)(0x20000024);
	   while((emcs_ctl & 0x00000002) != 0x00000002)
	   {
	   	emcs_ctl = *(volatile uint32 *)(0x20000024);
	   }  
    }
    //Refresh interval value is 0x0
    //Refresh prescale value is 0x96
    *(volatile uint32 *)(0x20000020) = 0x0022c800;
    *(volatile uint32 *)(0x20000024) |= 1<<5;
	
    for(i=0;i<100;i++);
#endif
    
    //Call Userdef_after_sdram_init()
    Userdef_after_sdram_init();
    
}