예제 #1
0
int parse_block(int fd1,int fd2)
{
    char tag;
    read(fd1,&tag,1);
    switch(GET_TAG(tag))
    {
	case 0x00:
	    parse_titleblock(fd1);
	    break;
	case 0x01:
	    parse_sheet(fd1);
	    break;
	case 0x02:
	    parse_component(fd1,fd2);
	    break;
	case 0x03:
	    parse_wire(fd1);
	    break;
	case 0x04:
	    parse_bus(fd1);
	    break;
	case 0x05:
	    parse_junction(fd1);
	    break;
	case 0x06:
	    parse_port(fd1);
	    break;
	case 0x07:
	    parse_label(fd1);
	    break;
	case 0x08:
	    parse_entry(fd1);
	    break;
	case 0x09:
	    parse_dashed(fd1);
	    break;
	case 0x0a:
	    parse_power(fd1);
	    break;
	case 0x0b:
	    parse_text(fd1);
	    break;
	case 0x0c:
	    parse_marker(fd1);
	    break;
	case 0x0f:
	    return 0;
	    break;
	default:
	    fprintf(stderr,"\nUnknown Block Tag\n");
	    exit(-1);
	    break;
    }


    return 1;
}
예제 #2
0
파일: exparser.cpp 프로젝트: tomas789/dx
exparser::return_type exparser::loop(const std::string& s) {
    if (s.empty()) return return_false;
    
    if (debug) std::cout << "PARSING : " << s << std::endl;

    if (debug) std::cerr << "Try parenthesis" << std::endl;
    return_type parenthesis = parse_parenthesis(s);
    if (parenthesis) return parenthesis;
    
    if (debug) std::cerr << "Try constant" << std::endl;
    return_type constant = parse_constant(s);
    if (constant) return constant;
    
    if (debug) std::cerr << "Try variable" << std::endl;
    return_type variable = parse_variable(s);
    if (variable) return variable;
    
    if (debug) std::cerr << "Try plus" << std::endl;
    return_type plus = parse_plus(s);
    if (plus) return plus;
    
    if (debug) std::cerr << "Try minus" << std::endl;
    return_type minus = parse_minus(s);
    if (minus) return minus;

    if (debug) std::cerr << "Try multiply" << std::endl;
    return_type multiply = parse_multiply(s);
    if (multiply) return multiply;
    
    if (debug) std::cerr << "Try divide" << std::endl;
    return_type divide = parse_divide(s);
    if (divide) return divide;
    
    if (debug) std::cerr << "Try poewr" << std::endl;
    return_type power = parse_power(s);
    if (power) return power;
    
    if (debug) std::cerr << "Try function" << std::endl;
    return_type function = parse_function(s);
    if (function) return function;

    return return_false;
}
예제 #3
0
static int cmd_radio_ping_pong(char *command)
{
    char power[8];
    uint8_t channel, tx_power;

    if (2 != sscanf(command, "radio_ping_pong %u %8s", &channel, power))
        return 1;
    if (11 > channel || channel > 26)
        return 1;
    tx_power = parse_power(power);
    if (255 == tx_power)
        return 1;

    char *err_msg = radio_ping_pong(channel, tx_power);
    if (NULL == err_msg)
        printf("ACK radio_ping_pong %u %s\n", channel, tx_power);
    else
        printf("NACK radio_ping_pong %s\n", err_msg);
    return 0;
}
예제 #4
0
파일: power.c 프로젝트: ram1/data-collector
void *read_power(void *chan) {
	debug_message(("THREAD READ 1\n"));

	char buffer[BUFFER_SIZE];
	int ch = *((int *)chan);

	/*Initialize after grabbing the input parameter, which is on the
	stack of the caller. Subsequently, the caller is allowed to 
	terminate*/
	states[ch] = INIT;

	error_message("- reading channel %d\n", ch);
	while (states[ch] != HALTED) {
		int n;
		struct timeval curr;
    		gettimeofday(&curr, NULL);

		/*Issue a read request. Since the trigger mode is immediate,
		a read will occur immediately and the data will be put
		on the output buffer. See the SCPI 34410A Agilent Programmer's
		Manual. Another method is to set the meter to read chunks of
		data on its own.*/
		myread(myfile[ch], "READ?", buffer);
		//myread(myfile[ch], "DATA:POIN?", buffer);
		//buffer[strlen(buffer)] = 0;
		//n = atoi(buffer);
		//fprintf(stderr, "- POWER: %d readings are available at time %ld\n",n, (curr.tv_sec*1000+curr.tv_usec/1000)- (st.tv_sec*1000+st.tv_usec/1000));
//		if (n > 0) {
//			myread(myfile[ch], "R? 50000", buffer);
//			if (strlen(buffer) > 4) {
				parse_power(buffer, ch);
				if (states[ch] == INIT) states[ch] = RUNNING;
//			}
//		}
	}

	debug_message(("THREAD READ 2\n"));
	states[ch] = TERMINATED;
	pthread_exit((void *)2);
}