Ejemplo n.º 1
0
static PyObject *
py_ds1302_set_time(PyObject *self, PyObject *args) {
	const unsigned char hour, min, sec;
	if (!PyArg_ParseTuple(args, "bbb", &hour, &min, &sec))
		return NULL;
	time_set(RTC_HOUR, to_bcd(hour));
	time_set(RTC_MIN, to_bcd(min));
	time_set(RTC_SEC, to_bcd(sec));
	Py_RETURN_NONE;
}
Ejemplo n.º 2
0
static PyObject *
py_ds1302_set_date(PyObject *self, PyObject *args) {
	const unsigned char date, month;
	const unsigned int year;
	if (!PyArg_ParseTuple(args, "ibb", &year, &month, &date))
		return NULL;
	time_set(RTC_DATE, to_bcd(date));
	time_set(RTC_MONTH, to_bcd(month));
	time_set(RTC_YEAR, to_bcd((unsigned char)(year - 2000)));
	Py_RETURN_NONE;
}
Ejemplo n.º 3
0
Archivo: rtc.c Proyecto: 0day-ci/xen
static void rtc_copy_date(RTCState *s)
{
    const struct tm *tm = &s->current_tm;

    ASSERT(spin_is_locked(&s->lock));

    s->hw.cmos_data[RTC_SECONDS] = to_bcd(s, tm->tm_sec);
    s->hw.cmos_data[RTC_MINUTES] = to_bcd(s, tm->tm_min);
    if ( s->hw.cmos_data[RTC_REG_B] & RTC_24H )
    {
        /* 24 hour format */
        s->hw.cmos_data[RTC_HOURS] = to_bcd(s, tm->tm_hour);
    }
    else
    {
        /* 12 hour format */
        int h = (tm->tm_hour % 12) ? tm->tm_hour % 12 : 12;
        s->hw.cmos_data[RTC_HOURS] = to_bcd(s, h);
        if ( tm->tm_hour >= 12 )
            s->hw.cmos_data[RTC_HOURS] |= 0x80;
    }
    s->hw.cmos_data[RTC_DAY_OF_WEEK] = to_bcd(s, tm->tm_wday);
    s->hw.cmos_data[RTC_DAY_OF_MONTH] = to_bcd(s, tm->tm_mday);
    s->hw.cmos_data[RTC_MONTH] = to_bcd(s, tm->tm_mon + 1);
    s->hw.cmos_data[RTC_YEAR] = to_bcd(s, tm->tm_year % 100);
}
Ejemplo n.º 4
0
// Display time to the display in a nice pretty way.
void display_time(){
  uint8_t adj_secs,adj_mins,adj_hours,h0,h1;

  // Adjust seconds based on fast, or slow, mode.
  if (mode == fast_clock){
    // Pretty easy, counting from (0-140)/2, display 0-60 twice.
    adj_secs = (time_secs / (secs_to_real_secs_divider / 2)) % 60;
  } else {
    // Slow clock.
    //
    // Harder, need to look at what minute it is as well.
    adj_secs = (time_secs / (secs_to_real_secs_divider * 2)) + ((time_mins % 2) * 30);
  }


  set_dots(false,true,true,true,true,false);

  //  By popular request... blah.
  adj_hours = time_hours;
  if (silly_hour_display){
    if (adj_hours >= 12){
      adj_hours = adj_hours - 12;
    } else {
      adj_hours = adj_hours;
      set_dots(false,false,true,true,true,false);
    }
    if (!adj_hours)
      adj_hours = 12; // blah, so much work for such sillyness
  }
  adj_hours = to_bcd(adj_hours);

  h0 = adj_hours / 16;
  if (!h0 && silly_hour_display)
    h0 = CHAR_BLANK; // remove leading zeros for hours
                     // admittedly this might be a nice feature for
                     // 24 hour mode too, although most standards include the
                     // leading zero.
                     
  h1 = adj_hours % 16;


  adj_mins = to_bcd(time_mins);
  adj_secs = to_bcd(adj_secs);
  display_digits(
                 h0,h1,
                 adj_mins / 16, adj_mins % 16,
                 adj_secs / 16, adj_secs % 16);
}
Ejemplo n.º 5
0
Archivo: Time.cpp Proyecto: epatel/Cosa
time_t::time_t(clock_t c, uint8_t zone)
{
  UNUSED(zone);
  uint16_t dayno = c / SECONDS_PER_DAY;
  day = (dayno % DAYS_PER_WEEK) + 1;
  year = 0;
  while (1) {
    uint16_t days = days_per(year);
    if (dayno < days) break;
    dayno -= days;
    year += 1;
  }
  year %= 100;
  month = 1;
  while (1) {
    uint8_t days = pgm_read_byte(&days_in[month]);
    if (is_leap(year) && (month == 2)) days += 1;
    if (dayno < days) break;
    dayno -= days;
    month += 1;
  }
  date = dayno + 1;
  hours = (c % SECONDS_PER_DAY) / SECONDS_PER_HOUR;
  minutes = (c % SECONDS_PER_HOUR) / SECONDS_PER_MINUTE;
  seconds = (c % SECONDS_PER_MINUTE);
  to_bcd();
}
Ejemplo n.º 6
0
static int optoscan_send_freq(RIG *rig, pltstate_t *state)
{
	unsigned char buff[OPTO_BUFF_SIZE];
	char md, pd;
	freq_t freq;
	rmode_t mode;

	freq = state->next_freq;
	mode = state->next_mode;

	memset(buff, 0, OPTO_BUFF_SIZE);

	to_bcd(buff, freq, 5 * 2); /* to_bcd requires nibble len */

	rig2icom_mode(rig, mode, 0, (unsigned char *) &md, (signed char *) &pd);
	buff[5] = md;

	/* read echo'd chars only...there will be no ACK from this command
	 *
	 * Note:
	 *	It may have waited fro pltstate->usleep_time before reading the echo'd
	 *	chars, but the read will be blocking anyway. --SF
	 * */
	return icom_transaction(rig, C_CTL_MISC, S_OPTO_NXT, buff, 6, NULL, NULL);

	return RIG_OK;
}
Ejemplo n.º 7
0
Archivo: rtc-dm.c Proyecto: CPFL/gxen
RTCState *rtc_init(int base, int irq)
{
    RTCState *s;
    time_t ti;
    struct tm *tm;
    int val;

    s = qemu_mallocz(sizeof(RTCState));
    if (!s)
        return NULL;

/* PC cmos mappings */
#define REG_IBM_CENTURY_BYTE        0x32
#define REG_IBM_PS2_CENTURY_BYTE    0x37
    time(&ti);
    tm = gmtime(&ti);		/* XXX localtime and update from guest? */
    val = to_bcd(s, (tm->tm_year / 100) + 19);
    rtc_set_memory(s, REG_IBM_CENTURY_BYTE, val);
    rtc_set_memory(s, REG_IBM_PS2_CENTURY_BYTE, val);

    register_ioport_write(base, 2, 1, cmos_ioport_write, s);
    register_ioport_read(base, 2, 1, cmos_ioport_read, s);

    register_savevm("mc146818rtc", base, 1, rtc_save, rtc_load, s);
    return s;
}
Ejemplo n.º 8
0
static void rtc_read_time(SysPortState *s)
{
    struct tm tm;

    qemu_get_timedate(&tm, 0);
    s->rtc_shift_out = (uint64_t)to_bcd(tm.tm_sec);
    s->rtc_shift_out |= (uint64_t)to_bcd(tm.tm_min) << 8;
    s->rtc_shift_out |= (uint64_t)to_bcd(tm.tm_hour) << 16;
    s->rtc_shift_out |= (uint64_t)to_bcd(tm.tm_mday) << 24;
    s->rtc_shift_out |= (uint64_t)tm.tm_wday << 32;
    s->rtc_shift_out |= (uint64_t)(tm.tm_mon + 1) << 36;
    s->rtc_shift_out |= (uint64_t)to_bcd(tm.tm_year % 100) << 40;
    if (s->rtc_mode & RTC_MODE_UPD4993A) {
        s->rtc_shift_out <<= 4;
    }
}
Ejemplo n.º 9
0
/* Convert given mcc and mnc to BCD and write to *bcd_dst, which must be an
 * allocated buffer of (at least) 3 bytes length. */
void gsm48_mcc_mnc_to_bcd(uint8_t *bcd_dst, uint16_t mcc, uint16_t mnc)
{
	uint8_t bcd[3];

	to_bcd(bcd, mcc);
	bcd_dst[0] = bcd[0] | (bcd[1] << 4);
	bcd_dst[1] = bcd[2];

	to_bcd(bcd, mnc);
	/* FIXME: do we need three-digit MNC? See Table 10.5.3 */
	if (mnc > 99) {
		bcd_dst[1] |= bcd[2] << 4;
		bcd_dst[2] = bcd[0] | (bcd[1] << 4);
	} else {
		bcd_dst[1] |= 0xf << 4;
		bcd_dst[2] = bcd[1] | (bcd[2] << 4);
	}
}
Ejemplo n.º 10
0
int frg100_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
  unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x0a};

   /* store bcd format in cmd (LSB) */
  to_bcd(cmd, freq/10, 8);

  /* Frequency set */
  return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
}
Ejemplo n.º 11
0
void gsm48_generate_lai(struct gsm48_loc_area_id *lai48, uint16_t mcc,
			uint16_t mnc, uint16_t lac)
{
	uint8_t bcd[3];

	to_bcd(bcd, mcc);
	lai48->digits[0] = bcd[0] | (bcd[1] << 4);
	lai48->digits[1] = bcd[2];

	to_bcd(bcd, mnc);
	/* FIXME: do we need three-digit MNC? See Table 10.5.3 */
	if (mnc > 99) {
		lai48->digits[1] |= bcd[2] << 4;
		lai48->digits[2] = bcd[0] | (bcd[1] << 4);
	} else {
		lai48->digits[1] |= 0xf << 4;
		lai48->digits[2] = bcd[1] | (bcd[2] << 4);
	}

	lai48->lac = htons(lac);
}
Ejemplo n.º 12
0
int m48_tod_set(int year,		/* 1980-2079 */
		int month,		/* 01-12 */
		int day,		/* 01-31 */
		int hour,		/* 00-23 */
		int minute,		/* 00-59 */
		int second)		/* 00-59 */

{
    SYS_TOD_UNPROTECT();

    M48_ADDR[CONTROL] |= 0x80;	/* Set WRITE bit */

    M48_ADDR[YEAR] = to_bcd(year % 100);
    M48_ADDR[MONTH] = to_bcd(month);
    M48_ADDR[DAY] = to_bcd(day);
    M48_ADDR[DAY_OF_WEEK] = day_of_week(year, month, day) + 1;
    M48_ADDR[HOUR] = to_bcd(hour);
    M48_ADDR[MINUTE] = to_bcd(minute);
    M48_ADDR[SECOND] = to_bcd(second);

    M48_ADDR[CONTROL] &= ~0x80;	/* Clear WRITE bit */

    SYS_TOD_PROTECT();

    return 0;
}
Ejemplo n.º 13
0
Archivo: rtc.c Proyecto: 7LK/McWRT
static void set_rtc_time(struct rtc_time *rtc_tm)
{
	rtc_tm->tm_sec  = to_bcd(rtc_tm->tm_sec);
	rtc_tm->tm_min  = to_bcd(rtc_tm->tm_min);
	rtc_tm->tm_hour = to_bcd(rtc_tm->tm_hour);
	rtc_tm->tm_mday = to_bcd(rtc_tm->tm_mday);
	rtc_tm->tm_mon  = to_bcd(rtc_tm->tm_mon + 1);
	rtc_tm->tm_year = to_bcd(rtc_tm->tm_year);

	if (rtc_tm->tm_year >= 0x100) {
		rtc_tm->tm_year -= 0x100;
		rtc_tm->tm_mon |= RTC_Y2K_MASK;
	}

	spin_lock_irq(&rtc_lock);
	i2c_start();
	i2c_outb(RTC_I2C_ADDRESS | I2C_WRITE_MASK);
	i2c_outb(0x00);	/* set starting register to 0 (=seconds) */
	i2c_outb(rtc_tm->tm_sec);
	i2c_outb(rtc_tm->tm_min);
	i2c_outb(rtc_tm->tm_hour);
	i2c_outb(rtc_tm->tm_wday);
	i2c_outb(rtc_tm->tm_mday);
	i2c_outb(rtc_tm->tm_mon);
	i2c_outb(rtc_tm->tm_year);
	i2c_stop();
	spin_unlock_irq(&rtc_lock);
}
Ejemplo n.º 14
0
static void rtc_set_date_from_host(RTCState *s)
{
    struct tm tm;
    int val;

    /* set the CMOS date */
    qemu_get_timedate(&tm, 0);
    rtc_set_date(s, &tm);

    val = to_bcd(s, (tm.tm_year / 100) + 19);
    rtc_set_memory(s, REG_IBM_CENTURY_BYTE, val);
    rtc_set_memory(s, REG_IBM_PS2_CENTURY_BYTE, val);
}
Ejemplo n.º 15
0
static uint32_t s3c_rtc_read(void *opaque, target_phys_addr_t addr)
{
    struct s3c_rtc_state_s *s = (struct s3c_rtc_state_s *) opaque;
    addr -= s->base;

    switch (addr) {
    case S3C_RTC_CON:
        return s->control;

    case S3C_RTC_TICNT:
        return s->tick;

    case S3C_RTC_ALM:
        return s->alarm;
    case S3C_RTC_ALMSEC:
        return s->almsec;
    case S3C_RTC_ALMMIN:
        return s->almmin;
    case S3C_RTC_ALMHOUR:
        return s->almhour;
    case S3C_RTC_ALMDATE:
        return s->almday;
    case S3C_RTC_ALMMON:
        return s->almmon;
    case S3C_RTC_ALMYEAR:
        return s->almyear;

    case S3C_RTC_RST:
        return s->reset;

    case S3C_RTC_BCDSEC:
        s3c_rtc_update(s);
        return to_bcd(s->tm.tm_sec);
    case S3C_RTC_BCDMIN:
        s3c_rtc_update(s);
        return to_bcd(s->tm.tm_min);
    case S3C_RTC_BCDHOUR:
        s3c_rtc_update(s);
        return to_bcd(s->tm.tm_hour);
    case S3C_RTC_BCDDATE:
        s3c_rtc_update(s);
        return to_bcd(s->tm.tm_mday);
    case S3C_RTC_BCDDAY:
        s3c_rtc_update(s);
        return s->tm.tm_wday;
    case S3C_RTC_BCDMON:
        s3c_rtc_update(s);
        return to_bcd(s->tm.tm_mon + 1);
    case S3C_RTC_BCDYEAR:
        s3c_rtc_update(s);
        return to_bcd(s->tm.tm_year % 100);
    default:
        printf("%s: Bad register 0x%lx\n", __FUNCTION__, addr);
        break;
    }
    return 0;
}
Ejemplo n.º 16
0
int frg8800_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
    unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x01};

    rig_debug(RIG_DEBUG_TRACE,"frg8800: frg8800_set_freq called\n");

    /* store bcd format in cmd (LSB) */
    to_bcd(cmd, freq/10, 8);

    /* Byte1: 100Hz's and 25Hz step code */
    cmd[0] = ( cmd[0]&0xf0 ) | ( 1 << ((((long long)freq)%100)/25) );

    /* Frequency set */
    return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
}
static void rtc_copy_date(RTCState *s)
{
    const struct tm *tm = &s->current_tm;

    s->cmos_data[RTC_SECONDS] = to_bcd(s, tm->tm_sec);
    s->cmos_data[RTC_MINUTES] = to_bcd(s, tm->tm_min);
    if (s->cmos_data[RTC_REG_B] & 0x02) {
        /* 24 hour format */
        s->cmos_data[RTC_HOURS] = to_bcd(s, tm->tm_hour);
    } else {
        /* 12 hour format */
        s->cmos_data[RTC_HOURS] = to_bcd(s, tm->tm_hour % 12);
        if (tm->tm_hour >= 12)
            s->cmos_data[RTC_HOURS] |= 0x80;
    }
    s->cmos_data[RTC_DAY_OF_WEEK] = to_bcd(s, tm->tm_wday);
    s->cmos_data[RTC_DAY_OF_MONTH] = to_bcd(s, tm->tm_mday);
    s->cmos_data[RTC_MONTH] = to_bcd(s, tm->tm_mon + 1);
    s->cmos_data[RTC_YEAR] = to_bcd(s, tm->tm_year % 100);
}
Ejemplo n.º 18
0
Archivo: ft100.c Proyecto: DF4OR/hamlib
int ft100_set_freq(RIG *rig, vfo_t vfo, freq_t freq) {
  struct rig_state *rig_s;
  unsigned char p_cmd[YAESU_CMD_LENGTH];
  unsigned char cmd_index;	/* index of sequence to send */

  if (!rig)  return -RIG_EINVAL;

  rig_s = &rig->state;

  rig_debug(RIG_DEBUG_VERBOSE,"ft100: requested freq = %"PRIfreq" Hz \n", freq);

  cmd_index = FT100_NATIVE_CAT_SET_FREQ;

  memcpy(p_cmd,&ncmd[cmd_index].nseq,YAESU_CMD_LENGTH);

  /* fixed 10Hz bug by OH2MMY */
  freq = (int)freq/10;
  to_bcd(p_cmd,freq,8);	/* store bcd format in in p_cmd */

  return write_block(&rig_s->rigport, (char *) p_cmd, YAESU_CMD_LENGTH);
}
Ejemplo n.º 19
0
int main (int argc, char *argv[])
{
	unsigned char b[(MAXDIGITS+1)/2];
	freq_t f=0;
	int digits = 10;
	int i;

	if (argc != 2 && argc != 3) {
			fprintf(stderr,"Usage: %s <freq> [digits]\n",argv[0]);
			exit(1);
	}

	f = (freq_t)atoll(argv[1]);
	if (argc > 2) {
		digits = atoi(argv[2]);
		if (digits > MAXDIGITS)
			exit(1);
	}

	printf("Little Endian mode\n");
	printf("Frequency: %"PRIfreq"\n",f);
	to_bcd(b, f, digits);
	printf("BCD: %2.2x",b[0]);
	for (i = 1; i < (digits+1)/2; i++)
		printf(",%2.2x",b[i]);
	printf("\nResult after recoding: %llu\n", from_bcd(b, digits));

	printf("\nBig Endian mode\n");
	printf("Frequency: %"PRIfreq"\n",f);
	to_bcd_be(b, f, digits);
	printf("BCD: %2.2x",b[0]);
	for (i = 1; i < (digits+1)/2; i++)
		printf(",%2.2x",b[i]);
	printf("\nResult after recoding: %llu\n", from_bcd_be(b, digits));

	return 0;
}
Ejemplo n.º 20
0
void main() {
        
    // TLC5940 dependent // init_5940();
    init_7_seg_4_digit();        
    init_rot();
    init_timer();
        init();

        TRISA.B0 = bit_out; // testing light matrix

        /* TLC5940 dependent
                                
    for(i = 0; i < STEPS; i++){
            change(sData, i, pattern[channel][i]);
    }

    sendData(sData, bitcount);  
        */

    INTCON2 = 0x04; 
	GIEH_bit = 1;
	GIEL_bit = 1;
    T0IE_bit = 1; // RE-ENABLE AFTER TESTING MIDI!
    TMR0ON_bit = 1; // clocks every 10us
	RC2IE_bit = 0; // MIDI receive interrupt

        drum_0 = 0;
        drum_1 = 0;   
        drum_2 = 0;
        drum_3 = 0;

        delay_ms(100);

        // init display
        push_light_matrix(pattern, channel);
        show_light_matrix();        

	state = FORWARD;

        // main loop
    while(1){
        
        if(switch_up == 0) state = FORWARD;
        else if(switch_down == 0) state = BACKWARD;
        else {
                state = STOPPED;
                        current_step = 0;
                }

		if(MIDI_state == MIDI_RECEIVED){
			pattern[0][this_MIDI_note - 0x24] = (~pattern[0][this_MIDI_note - 0x24] & 1);
			MIDI_state = IDLE;
			update_light_matrix( channel, selected_step, BRIGHTNESS, 0, 0);
		}
        
        // flip the pattern's selected_step with switch_0
        if ((switch_0 == _set) && (switch_0_flag != _set)) {
                pattern[channel][selected_step] = (~pattern[channel][selected_step] & _set);
                                update_light_matrix( channel, selected_step, BRIGHTNESS, 0, 0 );
                switch_0_flag = _set;
        }
        else if (switch_0 == _clr) {
                switch_0_flag = _clr;
        }

        // advance or retreat one step if running
        if (sixteenthcount >= (MS_BPM / tempo) && state != STOPPED) {
            sixteenthcount = 0;
                        drum_0 = pattern[0][current_step];
                        drum_1 = pattern[1][current_step];
                        drum_2 = pattern[2][current_step];
                        drum_3 = pattern[3][current_step];
              
       
                    current_step += state; // forward or backwards
            if(current_step <= -1){current_step = 15;}
                else if(current_step >= 16){current_step = 0;}
        }

        if (state != STOPPED) send_7seg(to_bcd(current_step * 100 + selected_step));
                else send_7seg(to_bcd(tempo));

                // turns off all outputs after uh, whatever that time is?
        if (sixteenthcount >= ((MS_BPM / tempo) / 4)) {
                drum_0 = off;
                drum_1 = off;
                drum_2 = off;
                drum_3= off;
        }   

                // shows blinking cursor
                current_status = pattern[channel][selected_step];
        if (blinkcount >= (BLINK_TIME /*>> (current_status * 2)*/)){
            blinkcount = 0;
            blink = ~blink;
            
                        push_light_matrix(pattern, channel);

            if(blink == 0) update_light_matrix(channel, selected_step, current_status * BRIGHTNESS, 0, 0);
            else update_light_matrix(channel, selected_step, 0, 0, BRIGHTNESS);

                        show_light_matrix();
        }
 
        // rotary left controls selected step
        last_rot_0 = this_rot_0;           
        this_rot_0 = (rot_0b << 1) | rot_0a;  
        selected_step += check_rotary(this_rot_0, last_rot_0);
        if(selected_step <= -1){selected_step = 15;}
        else if(selected_step >= 16){selected_step = 0;}
        
        // rotary right adjusts channel if running, tempo if stopped
        if(state != STOPPED){
            last_rot_1 = this_rot_1;           
            this_rot_1 = (rot_1a << 1) | rot_1b;  
            channel += check_rotary(this_rot_1, last_rot_1);
            if(channel <= -1){channel = 0;}
                        else if(channel >= 5){channel = 4;}
                }else{
            last_rot_1 = this_rot_1;           
            this_rot_1 = (rot_1a << 1) | rot_1b;  
            tempo += check_rotary(this_rot_1, last_rot_1);
            if(tempo <= 9){tempo = 10;}
                else if(tempo >= 251){tempo = 250;}                    
                }
        
        // TLC 5940 dep //sendData(sData, bitcount);
        // TLC 5940 dep //gsClock();
    }
}
Ejemplo n.º 21
0
static void * proc_control(void *args) {
	struct frame_manager *manager = get_frame_manager(CONTROL_MANAGER);
	struct record_manager * record_manager=get_record_manager();
	struct block_filter *filter = NULL;

	struct frame *pframe = NULL;
	struct block * pblock = NULL;
	char buffer[64];
	int length;
	char dest_addr = 0;
	char src_addr = 0;
	char operation = 0;
	char cmd = 0;
	char tmp;

	if (manager == NULL)
		return NULL;
	filter = get_frame_filter(manager);
	while (1) {
		pblock = get_block(filter, TIMEOUT_MAIN_UNIT, BLOCK_FULL);
		if (pblock != NULL) {
			set_sys_state(BIT5_MAIN_UNIT,STATE_MAINUNIT_OK);
			light_on(0);
			light_main_alarm(0);
			pframe = (struct frame*) pblock->data;
			pframe->length = pblock->data_length;
			dest_addr = destination_of_frame(pframe);
			src_addr = pframe->data[4];
			cmd = command_of_frame(pframe);
			operation = operation_of_frame(pframe);

			if (src_addr == MASTER_ADDRESS) {

				switch (dest_addr) {
				case RADIO_450M_ADDRESS:
					if ((operation == 0x03) && (cmd == 0x20)) { //向450M发送机车号
						char * cab_id = get_id();

						get_frame_real_data(pframe, buffer, &length);

						buffer[8] = 0;
						tmp = buffer[3];
						buffer[3] = 0;
						int cab_type = atoi(buffer);

						buffer[3] = tmp;

						sprintf(cab_id, "%s-%s", get_cab_code(cab_type),
								buffer + 3);

					}
					break;
				case ALL_MMI_ADDRESS:
					if ((operation == 0x03) && (cmd == 0x46)) { //关机命令

						flush_all_data(record_manager);
					}
					break;
				}

			}

			if (dest_addr == RECORD_ADDRESS) {

				switch (operation) {
				case 1: //维护信息
					// echo off
					tmp = 0;
					if (src_addr == 0x01) {
						tmp = 0x01;
					} else if ((src_addr == 0x03) || (src_addr == 0x04)) {
						tmp = 0x41;
					}
					send_frame(manager, RECORD_ADDRESS, src_addr, 1, tmp,
							pframe->data + 9, 2);

					switch (cmd) {
					case (char) 0x33: //播放控制
					{
						if (pframe->data[10] == (char) 0xff) {
							start_play(src_addr);
						} else if (pframe->data[10] == 0) {
							stop_play();
						}
					}
						break;
					case (char) 0xfa: //问询测试
						break;
					case (char) 0x34: //查询时钟
					{
						struct tm time;
						get_time(&time);

						buffer[0] = to_bcd(time.tm_year - 100); //year
						buffer[1] = to_bcd(time.tm_mon + 1);
						buffer[2] = to_bcd(time.tm_mday);
						buffer[3] = to_bcd(time.tm_hour);
						buffer[4] = to_bcd(time.tm_min);
						buffer[5] = to_bcd(time.tm_sec);
						send_frame(manager, RECORD_ADDRESS, src_addr, 1,
								(char) 0x91, buffer, 6);
					}
						break;
					case (char) 0x35: //设置时钟
						break;
					case (char) 0xa5: //查询软件版本
					{

						bcopy(version, buffer, 16);
						send_frame(manager, RECORD_ADDRESS, src_addr, 1,
								(char) 0xaa, buffer, 16);
					}
						break;

					}

					break;
				case 3: //不需要应答
					break;
				}
			}
			put_block(pblock, BLOCK_EMPTY);
		} else {
			set_sys_state(BIT5_MAIN_UNIT,STATE_MAINUNIT_FAIL);
			light_main_alarm(1);
		}
	}

	return NULL;
}