コード例 #1
0
ファイル: main.c プロジェクト: sergeykam/DISPI
void data_cout(void){
	if(DATA == status){
		printf("Asking data \n");
		status = BUSY;

		for(uint8_t i = 0; i < 1; i++){
			printf("Asking data from %d DIS, \n", dis[i].num);
			if(dis[i].status == DIS_STATUS_ACTIVE){
				if(!DIS_getData(dis[i].num, data_buf)){
					printf("Got data %X, %X, %X, %X, \n", data_buf[0],data_buf[1],data_buf[2],data_buf[3]);
					memcpy(data.data_buf, data_buf, 4);

					if(validate_data()){
						printf("Got data %f \n", data.data_var);
						clr_buf();

						error = dis_db_set_data(dis[i].num, data.data_var);

						if(error){
							printf("Failed to set data error: %d \n", error);
						}
					} else {
						printf("Data is not valid \n");
					}
				}
			}
		}

		status_next = IDLE;
	}
}
コード例 #2
0
ファイル: deal_fs.c プロジェクト: jamjr/Helios-NG
static void 
init_Sum_Block (void)

/*
*  Initialise the SummaryBlock after formatting the hard disc.
*/

{
	word i;
	struct sum_blk *sbp;
	Date date;
     	struct buf *bp;

	/* allocate a buffer and clear its contents */
	bp = getblk(filedrive,1,1,NOSAVE);
	clr_buf (bp);
	sbp = bp->b_un.b_sum;

	/* initialise the DirEntry of the RootDirectory */
	sbp->root_dir.de_inode.i_mode = DIR; 
	sbp->root_dir.de_inode.i_size = sizeof(struct dir_elem); 
	sbp->root_dir.de_inode.i_db[0] = 3; 	
	sbp->root_dir.de_inode.i_blocks = 1; 		
	sbp->root_dir.de_inode.i_spare = 0; 			
	strcpy(sbp->root_dir.de_name,fs_name);
	/* the root directory has an initial matrix giving full access */
	/* The system administrator should restrict this after setting */
	/* up any special links.				       */
	sbp->root_dir.de_inode.i_matrix = -1; 
	date = GetDate();
	sbp->root_dir.de_inode.i_ctime = date; 			
	sbp->root_dir.de_inode.i_atime = date; 			
	sbp->root_dir.de_inode.i_mtime = date; 		 			
	
	/* Initialise SummaryInformations */
	sbp->sum_same = TRUE;

	/* Initialise the first_boot flag */
	sbp->first_boot = TRUE;
	
	/* SummaryInfo of the first cylinder group */
	sbp->cg_sum[0].s_ndir = 1;
	sbp->cg_sum[0].s_nbfree = maxbpg - 4;
	sbp->fs_sum = sbp->cg_sum[0];

	/* SummaryInfo of the remaining cylinder groups */
	for (i=1; i<maxncg; i++) 
	{
		sbp->cg_sum[i].s_ndir = 0;
		sbp->cg_sum[i].s_nbfree = maxbpg - 1;
		sbp->fs_sum.s_ndir += sbp->cg_sum[i].s_ndir;
		sbp->fs_sum.s_nbfree += sbp->cg_sum[i].s_nbfree;		
	}
		
	/* write to hard disc */
	bwrite(bp->b_tbp);						
}
コード例 #3
0
ファイル: deal_fs.c プロジェクト: jamjr/Helios-NG
static void 
init_Boot_Block (void)

/* 
*  Since there isn't any BootBlock yet, simply clear the contents
*  of the first block on disc.
*/

{
     	struct buf *bp;

	bp = getblk(filedrive,0,1,NOSAVE);
	clr_buf (bp);
	bwrite(bp->b_tbp);						
}
コード例 #4
0
/* Entry point */
void main(void) {
	start_up_delay();      
	safe_op();
	gsm_uart_init();    
	gpio_port(); 
	PORTBbits.RB0 = 1; // A/B // gsm modem connected      
	gsm = ON;  
	modem_init();
	PORTAbits.RA1 = LED_ON;

	/* Keep looping until powered off */
	while(1) {
		clr_buf(); 
		clean_sim();
		PORTAbits.RA0 = LED_ON;
		wait_4_msg();       
		get_index();  
		read_msg();
		check_msg();
		PORTAbits.RA6 = LED_ON;
		if(success == 1) {  
			get_mob_no();      
			send_msg_cmd();           
			gsm = OFF;
			PORTCbits.RC0 = LED_ON; 
			gps_handler();
			PORTCbits.RC1 = LED_ON; 
			gsm = ON;
			gsm_uart_init();  
			PORTBbits.RB0 = 1;        // A/B ---> gsm modem connected  
			INTCONbits.GIEH = 1;      // Enable all unmasked interrupt           
			send_loc(); 
			PORTCbits.RC2 = LED_ON;
			for(k=60000; k>5; k--); 
			PORTAbits.RA0 = LED_OFF;
			PORTAbits.RA6 = LED_OFF;
			PORTCbits.RC0 = LED_OFF;
			PORTCbits.RC1 = LED_OFF;
			PORTCbits.RC2 = LED_OFF;  
		}else {
			PORTAbits.RA0 = LED_OFF;
			PORTAbits.RA6 = LED_OFF;
		} 
	}            	                 
}
コード例 #5
0
ファイル: main.c プロジェクト: sergeykam/DISPI
void conf_cout(void){
	if(CONF == status){
		status = BUSY;

		for(uint8_t i = 0; i < 1; i++){
			printf("Asking conf from %d DIS \n", dis[i].num);

			if(!DIS_getConf(dis[i].num, data_buf)){
				printf("Got config %X, %X, %X, %X \n", data_buf[0],data_buf[1],data_buf[2],data_buf[3]);

				config.dis_num = dis[i].num;

				config.sensor_type = data_buf[0];
				config.gas = data_buf[1];
				config.dim = data_buf[2];
				config.voltage = data_buf[3];

				clr_buf();

				if(validate_conf()){
					error = dis_db_set_conf(&config);

					if(error){
						dis[i].status = DIS_STATUS_NONE;
						dis_db_del_conf(dis[i].num);
						printf("Failed to set conf error: %d \n", error);
					} else {
						dis[i].status = DIS_STATUS_ACTIVE;
					}
				} else {
					printf("Not valid CONF \n");
				}
			} else {
				printf("Failed to get conf DIS #%d \n", dis[i].num);
				dis[i].status = DIS_STATUS_NONE;
				dis_db_del_conf(dis[i].num);
			}
		}

		status_next = IDLE;
	}
}
コード例 #6
0
ファイル: os_viewc.c プロジェクト: flyoo/gprs
void data_analysis (char u8_data)
{
	switch(stat) {
		case DATA_CHECKING :
			if(cursor_of_buf < BUF_SIZE) {
				buf[buf_x][cursor_of_buf] = u8_data;
				cursor_of_buf++;
				if(u8_data == '<') {
					stat = TAIL_CHECKING;
					tail_cnt = 1;
				}
				break;
			} else {
				perr("BUF_SIZE full!\n");
				stat = NONE_CHECKING;
				clr_buf(buf_x);
				cursor_of_buf = 0;
				return;
			}
		case NONE_CHECKING :
			if(u8_data == '>') {
				stat = HEAD_CHECKING;
				buf[buf_x][0] = '>';
				cursor_of_buf = 1;
				break;
			} else {
				return;
			}
		case HEAD_CHECKING :
			if(cursor_of_buf < 3) {
				buf[buf_x][cursor_of_buf] = u8_data;
				cursor_of_buf++;
			}
			if(cursor_of_buf == 3) {
				if( (buf[buf_x][0] == '>') &&(buf[buf_x][1] == '>') &&(buf[buf_x][2] == '>')) {
					stat = DATA_CHECKING;
					break;
				} else {
					stat = NONE_CHECKING;
					clr_buf(buf_x);
					cursor_of_buf = 0;
					break;
				}				
			}
			break;
		case TAIL_CHECKING :
			if(cursor_of_buf < BUF_SIZE) {
				buf[buf_x][cursor_of_buf] = u8_data;
				cursor_of_buf++;
                tail_cnt++;
				if(tail_cnt == 3) {
                    if( (buf[buf_x][cursor_of_buf-1] == '<') &&
                        (buf[buf_x][cursor_of_buf-2] == '<') &&
                        (buf[buf_x][cursor_of_buf-3] == '<')) {
                        		buf[buf_x][cursor_of_buf] = '\0';
                             buf_ok = buf_ok | (1<<buf_x);
					printf("buf_x = %d is ok\n",buf_x);
                                  AppGprsSendRxMboxData = buf_ok;
                                  OSMboxPost(AppGprsSendRxMbox, &AppGprsSendRxMboxData);
					stat = NONE_CHECKING;
					if(buf_x < BUF_CNT) {
						buf_x++;
						cursor_of_buf = 0;
					} else {
						buf_x = 0;//need check buf_x is empty?
					}
					break;
                    }
                }
                break;
			} else {
				 perr("BUF_SIZE full!\n");
				 stat = NONE_CHECKING;
				 clr_buf(buf_x);
			     cursor_of_buf = 0;
				 return;
			}
		default:
			return;
	}
}