bool PIOS_Hsync_ISR()
{
    // On tenth line prepare data which will start clocking out on GRAPHICS_LINE+1
    if (Hsync_update == GRAPHICS_LINE) {
        prepare_line(0);
        gActiveLine = 1;
    }
    Hsync_update++;
    return true;
}
Beispiel #2
0
static int parse_header_line( char* line, char** pkey, char** pvalue )
{
	char* s;
	char* end;
	char* key_end;
	char c;

	s = prepare_line( line, &end );
	if( *s == '\0' )
	{
		return 1;
	}

	*pkey = s;
	while( ( c = *s ) != '=' && c != ' ' && c != '\t' )
	{
		if( c == '\0' )
		{
			fprintf( stderr, "kum error: invalid header format.\n" );
			exit( 1 );			
		}

		++s;
	}

	key_end = s;
	s = (char*) skip_ws( s );
	if( key_end == *pkey || *s != '=' )
	{
		fprintf( stderr, "kum error: invalid header format.\n" );
		exit( 1 );			
	}

	*key_end = '\0';
	++s;

	s = (char*) skip_ws( s );

	if( *s != '\"' && *s != '\'' )
	{
		*pvalue = s;
	}
	else
	{
		/* Removing quotes */
		*pvalue = s + 1;
		
		if( end > *pvalue && *(end - 1) == *s )
		{
			*--end = '\0';
		}
	}
	
	return 1;
}
Beispiel #3
0
static void draw_tree(struct wdgt *w)
{
	struct process *p;
	/* init scr output function */
	scr_output_start(w);
	if(!begin) {
		scr_maddstr(w, "User has logged out", 0, 0, 20);
		return;
	}
	for(p = begin; p ;p = p->next) {
		if(!p->proc) continue;
		scr_addfstr(w, prepare_line(w, p), p->line, 0);
	}
	scr_output_end(w);
}
Beispiel #4
0
/**
 * DMA transfer complete interrupt handler
 * Note: This function is called for every line (~13k times / s), so we use direct register access for
 * efficiency
 */
void PIOS_VIDEO_DMA_Handler(void)
{	
//	vPortEnterCritical();
//	taskENTER_CRITICAL();
	// Handle flags from DMA stream channel
	if ((DMA2->LISR & DMA_FLAG_TCIF3) && (DMA1->HISR & DMA_FLAG_TCIF4)) {

		// Flush the SPI
		while ((OSD_LEVEL_SPI->SR & SPI_I2S_FLAG_TXE) == 0) {
			;
		}
		while (OSD_LEVEL_SPI->SR & SPI_I2S_FLAG_BSY) {
			;
		}
		while ((OSD_MASK_SPI->SR & SPI_I2S_FLAG_TXE) == 0) {
			;
		}
		while (OSD_MASK_SPI->SR & SPI_I2S_FLAG_BSY) {
			;
		}

		// Disable the SPI, makes sure the pins are LOW
		OSD_MASK_SPI->CR1 &= (uint16_t)~SPI_CR1_SPE;
		OSD_LEVEL_SPI->CR1 &= (uint16_t)~SPI_CR1_SPE;

		if (active_line < pios_video_type_cfg_act->graphics_hight_real) { // lines existing
			prepare_line();
		} else { // last line completed
			// Clear the DMA interrupt flags
			DMA2->LIFCR  |= DMA_FLAG_TCIF3;
			DMA1->HIFCR |= DMA_FLAG_TCIF4;

			// Stop pixel timer
			PIXEL_TIMER->CR1  &= (uint16_t) ~TIM_CR1_CEN;

			// Disable the pixel timer slave mode configuration
			PIXEL_TIMER->SMCR &= (uint16_t) ~TIM_SMCR_SMS;
			// Stop DMA
			OSD_MASK_DMA->CR  &= ~(uint32_t)DMA_SxCR_EN;
			OSD_LEVEL_DMA->CR &= ~(uint32_t)DMA_SxCR_EN;
		}
	}
//	vPortExitCritical();
//	taskEXIT_CRITICAL();
}
Beispiel #5
0
/**
 * ISR Triggered by line_counter, starts clocking out pixels for first visible OSD line
 */
void TIM4_IRQHandler(void)
{
//	vPortEnterCritical();
//	taskENTER_CRITICAL();
	
	if(TIM_GetITStatus(LINE_COUNTER_TIMER, TIM_IT_Update) && (active_line == 0))
	{
		// Clear the interrupt flag
		LINE_COUNTER_TIMER->SR &= ~TIM_SR_UIF;

		// Prepare the first line
		prepare_line();

		// Hack: The timing for the first line is critical, so we output it again
		active_line = 0;

		// Get ready to count the remaining lines
		LINE_COUNTER_TIMER->CNT = pios_video_type_cfg_act->graphics_line_start + y_offset;
		TIM_Cmd(LINE_COUNTER_TIMER, ENABLE);
	}
//	vPortExitCritical();
//	taskEXIT_CRITICAL();
}
Beispiel #6
0
static void kum_read_header( kum_file* kum, FILE* fp )
{
	char line[ MAX_LINE_SIZE ];
	char* key;
	char* value;
	char* s;

	while( fgets( line, MAX_LINE_SIZE, fp ) != NULL )
	{
		s = prepare_line( line, NULL );
		if( *s == '\0' )
		{
			continue;
		}

		
		if( strcmp( s, "BEGIN CHARMAP" ) == 0 )
		{
			break;
		}


		parse_header_line( line, &key, &value );
		
//		fprintf( stderr, "\'%s\' = \'%s\'\n", key, value );

		if( strcmp( "name", key ) == 0 )
		{
			strcpy( kum->name, value );
		}
		else if( strcmp( "type", key ) == 0 )
		{
			if( strcmp( value, "SBCS" ) == 0 )
			{
				kum->conv_type = KUM_SBCS;
			}
			else if( strcmp( value, "DBCS" ) == 0 )
			{
				kum->conv_type = KUM_DBCS;
			}
			else if( strcmp( value, "MBCS" ) == 0 )
			{
				kum->conv_type = KUM_MBCS;
			}
			else
			{
				fprintf( stderr, "kum error: invalid 'type' value\n." );
				exit( 1 );				
			}
		}
		else if( strcmp( "min_char_len", key ) == 0 )
		{
			char* end;
			kum->min_char_len = strtol( value, &end, 10 );
			if( kum->min_char_len <= 0 || *end != '\0' )
			{
				fprintf( stderr, "kum warning: invalid value of 'min_char_len'.\n" );
			}
		}
		else if( strcmp( "max_char_len", key ) == 0 )
		{
			char* end;
			kum->max_char_len = strtol( value, &end, 10 );
			if( kum->max_char_len <= 0 || *end != '\0' )
			{
				fprintf( stderr, "kum warning: invalid value of 'max_char_len'.\n" );
			}
		}
		else if( strcmp( "sub_char", key ) == 0 )
		{
			uint8_t bytes[ KUCONV_MAX_CHAR_LEN ];
			int8_t len;

			s = value;
			len = kum_parse_bytes( bytes, line, &s );
			if( len < 1 || len > 4 || *s != '\0' )
			{
				fprintf( stderr, "kum error: invalid value of 'sub_char'.\n" );
				exit( 1 );
			}
			
			kum->sub_char_len = len;
			memcpy( kum->sub_char, bytes, len );
		}
		else if( strcmp( "sub_char1", key ) == 0 )
		{
			uint8_t bytes[ KUCONV_MAX_CHAR_LEN ];
			int8_t len;

			s = value;
			len = kum_parse_bytes( bytes, line, &s );
			if( len != 1 || *s != '\0' )
			{
				fprintf( stderr, "kum error: invalid value of 'sub_char'.\n" );
				exit( 1 );
			}
			
			kum->sub_char1 = bytes[ 0 ];
		}
		else if( strcmp( "state", key ) == 0 )
		{
			switch( kum->conv_type )
			{
			case KUM_SBCS:
			case KUM_DBCS:
				kum->conv_type = KUM_MBCS;
				break;
			case KUM_MBCS:
				break;
			default:
				fprintf( stderr, "kum error: 'state' entry before the 'type'.\n");
				exit( 1 );
			}

			kum_add_state( &kum->states, value );
		}
		else
		{
			fprintf( stderr, "kum warning: unknown header value '%s'.\n", key );
		}
		
	}
}
Beispiel #7
0
int write_cabrillo(void)
{
    extern char* cabrillo;
    extern char logfile[];
    extern char exchange[];
    extern char call[];

    char* cab_dfltfile;
    struct cabrillo_desc *cabdesc;
    char cabrillo_tmp_name[80];
    char buffer[4000] = "";

    FILE *fp1, *fp2;
    struct qso_t *qso;

    if (cabrillo == NULL) {
	info("Missing CABRILLO= keyword (see man page)");
	sleep(2);
    	return(1);
    }

    /* Try to read cabrillo format first from local directory.
     * Try also in default data dir if not found.
     */
    cabdesc = read_cabrillo_format("cabrillo.fmt", cabrillo);
    if (!cabdesc) {
	cab_dfltfile = g_strconcat(PACKAGE_DATA_DIR, G_DIR_SEPARATOR_S,
	    "cabrillo.fmt", NULL);
	cabdesc = read_cabrillo_format(cab_dfltfile, cabrillo);
	g_free(cab_dfltfile);
    }

    if (!cabdesc) {
    	info("Cabrillo format specification not found!");
	sleep(2);
	return(2);
    }

    /* open logfile and create a cabrillo file */
    strcpy(cabrillo_tmp_name, call);
    g_strstrip(cabrillo_tmp_name); /* drop \n */
    strcat(cabrillo_tmp_name, ".cbr");

    if ((fp1 = fopen(logfile, "r")) == NULL) {
	info("Can't open logfile.");
	sleep(2);
	free_cabfmt( cabdesc );
	return (1);
    }
    if ((fp2 = fopen(cabrillo_tmp_name, "w")) == NULL) {
	info("Can't create cabrillo file.");
	sleep(2);
	free_cabfmt( cabdesc );
	fclose(fp1);		//added by F8CFE
	return (2);
    }


    /* ask for exchange and header information */
    ask(buffer, "Your exchange (e.g. State, province, age etc... (# if serial number)): ");
    strncpy(exchange, buffer, 10);
    getsummary( fp2 );

    info("Writing cabrillo file");

    while ((qso = get_next_record(fp1))) {

	prepare_line(qso, cabdesc, buffer);

	if (strlen(buffer) > 5)
	    fputs(buffer, fp2);

	free_qso(qso);
    }

    fclose(fp1);

    fputs("END-OF-LOG:\n", fp2);
    fclose(fp2);

    free_cabfmt( cabdesc );

    return 0;
}
Beispiel #8
0
/* safer malloc */
void *hk_malloc (hk_scratchpad *line_in, size_t sz) {
    prepare_line (line_in);
    TRY ((*line_in)->mem = malloc (sz));
    return (*line_in)->mem;
}