From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16245 invoked by alias); 5 Feb 2003 05:26:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 16225 invoked by uid 71); 5 Feb 2003 05:26:01 -0000 Resent-Date: 5 Feb 2003 05:26:01 -0000 Resent-Message-ID: <20030205052601.16223.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, gillies@cs.ubc.ca Received: (qmail 15991 invoked by uid 48); 5 Feb 2003 05:24:55 -0000 Message-Id: <20030205052455.15990.qmail@sources.redhat.com> Date: Wed, 05 Feb 2003 05:26:00 -0000 From: gillies@cs.ubc.ca Reply-To: gillies@cs.ubc.ca To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c/9578: ss2_main.c:708: Internal compiler error in `build_insn_chain', at global.c:1756 X-SW-Source: 2003-02/txt/msg00245.txt.bz2 List-Id: >Number: 9578 >Category: c >Synopsis: ss2_main.c:708: Internal compiler error in `build_insn_chain', at global.c:1756 >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Feb 05 05:26:01 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Donald W. Gillies >Release: gcc version 2.95.3 20010315 (release) [FreeBSD] >Organization: >Environment: FreeBSD >Description: Sorry, i don't have time to search GNATS to see if this one has been closed. My company shuts its doors on monday. gcc -DTARGET_IS_UNIX -DGIP_DEBUG -DGICMP_DEBUG -DUTGIP -DSHELL -g -fshort-enums -fshort-double -fno-common -pedantic-errors -W -Wall -Wimplicit -Wimplicit-int -Wreturn-type -Wswitch -Wunused -Wshadow -Wpointer-arith -Wcast-align -Waggreg ate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnes ted-externs -Werror -Wbad-function-cast -Wformat -Wwrite-strings -Wcast-qual -Wr edundant-decls -Wuninitialized -O -DNDEBUG unix.c systm.c lxt.c sensor.c crc.c slip.c onewire.c spiu.c smu.c seru.c adcu.c sensoru.c flashu.c mac.c mactune.c gip.c gicmp.c gtable.c ss2_main.c sh_cmd.c sh_main.c ss2_flash21.c ss2_main.c: In function `main': ss2_main.c:708: Internal compiler error in `build_insn_chain', at global.c:1756 Please submit a full bug report. See for instructions. *** Error code 1 Stop in /usr/home/gillies/gcc_error. >How-To-Repeat: include files available upon request. please contact gillies@cs.ubc.ca for more info. > gcc -v Using builtin specs. gcc version 2.95.3 20010315 (release) [FreeBSD] >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="ss2_main.c" Content-Disposition: inline; filename="ss2_main.c" /* * FILE: ss2_main.c * TARGET: cygnal 8051 * SYSTEM: bart-family * AUTHOR: * DESCRIPTION: Simplified sunscreen application (using temperature) * * Copyright (C) 2001-2002, Graviton Inc., San Diego, CA. All Rights Reserved. */ /*============================= INCLUDES ==============================*/ #include "cdefs.h" #include "types.h" #include "assert.h" /* OPTIONAL */ #include "stddef.h" #include "systm.h" #define TARGET_FULL #include "target.h" /* MAKE SURE TO #include ut_gip.h in target.h */ #include "mac.h" #include "gip.h" //#include "ram.h" #include /* get abs() */ #include "sunstrct.h" #include "app.h" #include "ss2_conf.h" #include "ss2_flash21.h" #include "sh.h" #define TARGET_CPU_CYGNAL_C8051F021 //#include "ss2_c8051f02x.h" #define MAX_PAYLOAD GIP_PAYLOAD - GIP_HDR_END - 1 #define TITLE "SunScreen II" #define RELEASE "Rel 1.1.3 (1/21/2003)" #define COPYRIGHT "C Graviton, Inc." #define SLIP_CHAR 0xc0 #define ESCAPE_CHAR 0xdb #define ESCAPED_EOM 0xdc #define ESCAPED_ESCAPE 0xdd #define HEARTBEAT_PERIOD 60 #define HUB_INIT_TIME 600 #define HUB_NO_ACTIVITY 300 #define REP_NO_ACTIVITY 1200 #define LUD_NO_ACTIVITY 30 #define VPM_NO_ACTIVITY 900 #define GID_NO_ACTIVITY 180 #define WATCHDOG_ENABLED #define WATCHDOG(X) X //#define SUNSCREEN_EMULATION //#define HUBAT9600BAUD #define AUTO_ENABLE /*============================= TYPEDEFS ==============================*/ /*--------------- Configuration Defination ----------------------------*/ struct Configuration_s { u_vchar_t operation_mode; u_vint16_t sampleperiod; u_vint16_t alarmperiod; u_vchar_t verbose; u_vchar_t xmitpower; u_vchar_t serialfmt; u_vchar_t detector; u_vchar_t alarm_source[2]; u_vchar_t hub_id[6]; u_vchar_t PN_sequence; }; /*---------------------------------------------------------------------*/ #define CONVERSION_TIMEOUT 2 #define toupper(a) (a & 0xdf) #define isnumber(a) (a >= '0') && (a <= '9') #define ishex(a) ((a >= '0') && (a <= '9')) ||((a >= 'A') && (a <= 'F')) #define lc_hex(a) (a >= 'a') && (a <= 'f') #define lc_char(a) (a >= 'a') && (a <= 'z') #define isprintable(a)(a >= ' ') #define watchdog_reset WDTCN = 0xa5 enum {REPORT_DISABLED, REPORT_PENDING, REPORT_ENABLED, REPORT_FAULT}; /*============================= CONSTANTS =============================*/ /*========================== GLOBAL VARIABLES =========================*/ u_char_t suns_genPid; char_t msg_buf[64]; u_char_t ta[128]; _data union { struct radio_s ss; u_char_t sensor_string[sizeof(struct radio_s)]; } SensorData; #define Config_Len sizeof(struct Configuration_s) union { struct Configuration_s config_struct; u_char_t config_string[Config_Len]; } _idata Configuration; u_char_t adc_ch_index; u_char_t SS1_message_type; secs16_t init_clock; secs16_t sensor_report_clock; // flash dependent secs16_t inactivity_clock; // sensor/flash dependent secs16_t heartbeat_clock; secs16_t adc_read_clock; secs16_t repeater_verbose_clock; secs16_t repeater_mac_clock; secs16_t secs_clock; secs16_t sensor_report_period; // actual period secs16_t inactivity_period; // actual period u_char_t report_now; u_char_t report_enabled; textptr_t hub_boot_msg = "HUBBOOT"; textptr_t hub_init_msg = "HUBINIT"; /*========================= FUNCTION PROTOTYPES =======================*/ char Atohex (unsigned char y); char hextoA (unsigned char y); char highnibble (char x); char lownibble (char x); void format_ludlum_msg(u_char_t *buf,struct detector_type *r); void format_tv_serial_msg(struct detector_type *sd, char *s); void format_vpm_msg(u_char_t *buf,u_char_t l,struct detector_type *s); void format_gid3_msg(u_char_t *buf,struct detector_type *s); void format_grs_msg(u_char_t *buf,int l,struct detector_type *s); u_char_t encode_radio_data(u_char_t msg_type, struct radio_s *ds); u_char_t read_volttemp(u_char_t op_index, struct radio_s *l_sd); void userif (void); void init_scratchpad(void); u_char_t read_scratchpad (vint16_t addr); void write_scratchpad (vint16_t addr,u_char_t d); u_vchar_t erase_scratchpad (void); u_char_t check_configuration(void); void show_configuration(void); boolean_t sensor_get_temp_volts(void); int_t getnum(void); void getid(textptr_t string, macpad_t *id); char getuchar(void); void transmit(u_char_t msg_type); u_char_t encode_msg(struct radio_s *sd,u_char_t *s); void encode_SS1_msg(struct radio_s *sd,char *s); void read_id(u_char_t *s); void printds(u_char_t len); secs16_t check_period(secs16_t period); u_int16_t process_msg_msg(u_char_t *s,u_char_t len); u_char_t encode_repeater_msg(char *s,u_char_t l); void showmac(u_vchar_t *s); /*============================= FUNCTIONS =============================*/ /* this function receives upcalls for application packets */ enum GICMP_Type_t app_listener(packetptr_t packet) { struct radio_s *sd; enum GICMP_Type_t retval = GICMP_OK; u_char_t s_len; gipptr_t g = (gipptr_t) packet->p->bytes; sd = (struct radio_s *) (packet->p->bytes + GIP_HDR_LTH); if (Configuration.config_struct.verbose >= ENABLE_DATA_OUTPUT) { if (g->protocol == GIPP_SUNSCREEN) { if (Configuration.config_struct.verbose >= SHOW_MESSAGES) { // ser_showmac("app listener: ", g->osource.bytes); retval = APPE_OK;} } else { retval = APPE_LISTEN;} // v1.12 : GIPE_OK -> APPE_OK s_len = encode_msg(sd,ta); if (report_enabled == REPORT_ENABLED) {printds(s_len);} // mac_free(packet); } return(retval);} /*---------------------------------------------------------------------------*/ /* this function receives upcalls for GICMP error packets */ enum APP_Err_t app_error(packetptr_t packet) { // v1.12 if (Configuration.config_struct.verbose >= SHOW_MESSAGES) { gip_printf("icmp: ", packet); } // print icmp packet on console return(APPE_OK);} // v1.12 /***************************************************************************** *****************************************************************************/ int_t main(void) { secs16_t clock; u_int16_t msg_type; u_char_t i,j; u_char_t c; u_char_t repeater_verbose_mode,data_fresh,time_ready; u_char_t len,serial_ndx; enum GIP_Role_t role=0x00; u_vchar_t serial_buf[200]; SYS_HexClock_t *ts; u_int16_t app_tx,app_rx; /*---------------------------------------------------------------------------*/ /* Start of main code */ /*---------------------------------------------------------------------------*/ watchdog_reboot: WATCHDOG(for(;;)); goto reboot; reboot: SYS_Init(SYS_115k); timer_init(); spi_init(); mac_init_onewire(); // get the macid from dallas chip SYS_InterruptInit(); printf("\n%s %s",TITLE,RELEASE); printf("\n%s",COPYRIGHT); // init_scratchpad(); FLASH_Init(); printf("\nReading configuration\n"); #ifndef unix for (i = 0; i < Config_Len; ++i) { // Configuration.config_string[i] = read_scratchpad ((vint16_t) i); FLASH_ReadScratch(i,&j); Configuration.config_string[i] = j; } #else bzero(&Configuration, sizeof(Configuration)); #endif if (check_configuration()) { show_configuration();} else { printf("\nERROR: ***Configuration not Valid***\n"); } clock = SYS_GetSecs(); printf("Initializing\n(press space bar for config mode, ESC for shell)"); for (i = 0; i < 5; i++) { if (SYS_Select(SYS_IO_SERIAL)) { c = _getkey(); if (c == ' ') { putchar('\n'); userif (); goto reboot; } else if (c == SER_ESCAPE) { putchar('\n'); mac_enable = FALSE; // disable mac sh_start(); mac_enable = TRUE; // re-enable mac goto reboot; } } printf("..." _bd_, 5 - i); ser_flush(); while(!SYS_Timeout(&clock, 1)); } if (!check_configuration()) {goto reboot;} /* if not ready, don't go on */ putchar('\n'); printf("Starting in "); switch (Configuration.config_struct.operation_mode) { /*----------------------- SENSOR MODE ----------------------------------*/ case SENSOR_MODE: { printf("Sensor mode\n"); ser_close(); if (Configuration.config_struct.detector < END_EXTERNAL_SENSOR_LIST) { SYS_ConsoleInit(sensor_type[Configuration.config_struct.detector].baudrate); } else { SYS_ConsoleInit(SYS_115k); } /* program serial port to trigger on CR */ switch (Configuration.config_struct.detector) { case NO_SENSOR: {break;} case LUDLUM375: { ser_dev[0].d.framing = 0x0a; // serial trigger-char for serial packet inactivity_period = LUD_NO_ACTIVITY; break;} case GRS: { /* Graviton Radiation Sensor */ ser_dev[0].d.framing = 0x0a; // serial trigger-char for serial packet break;} case VPM: { ser_dev[0].d.framing = 0x0a; // serial trigger-char for serial packet inactivity_period = VPM_NO_ACTIVITY; break;} case GID3: { ser_dev[0].d.framing = 0x0d; // serial trigger-char for serial packet inactivity_period = GID_NO_ACTIVITY; break;} default: {break;} } // ser_dev[0].d.framing = SER_CR; // serial trigger-char for serial packet ser_dev[0].d.has_framing = TRUE; // enable trigger-char upcalls break;} /*----------------------- PRIMARY HUB MODE ------------------------------*/ case PRIMARY_HUB_MODE: { printf("Primary Hub mode\n"); role = GIPR_Root1; #ifdef HUBAT9600BAUD ser_close(); SYS_ConsoleInit(SYS_9600); #endif /* program serial port to trigger on CR */ ser_dev[0].d.framing = SLIP_CHAR; // serial trigger-char for serial packet ser_dev[0].d.has_framing = TRUE; // enable trigger-char upcalls inactivity_period = HUB_INIT_TIME; break;} /*----------------------- SECONDARY HUB MODE ----------------------------*/ case SECONDARY_HUB_MODE: { printf("Secondary Hub mode\n"); break;} /*----------------------- ROUTING MODE ----------------------------------*/ case ROUTING_MODE: { printf("Routing Node mode\n"); break;} /*----------------------- DEFAULT/ERROR MODE ----------------------------*/ default: { printf("Default case, Error mode\n"); break;} } /* end of switch */ /*---------------------------------------------------------------------------*/ /* END OF CONFIGURATION, START PROCESSING */ /*---------------------------------------------------------------------------*/ adc_init(TRUE); // start ADC without interrupts mac_init_onewire(); mactune_offset = Configuration.config_struct.PN_sequence; gip_init(); bcopy(Configuration.config_struct.hub_id, MAC_ROOT_UID.bytes, MAC_UID_LTH); SYS_InterruptInit(); LXT_SetXmtPwr(Configuration.config_struct.xmitpower); app_tx = mac_stats.tx; app_rx = mac_stats.rx; /* normal report time */ if (Configuration.config_struct.alarm_source[0] == No_Alarm_Report) { sensor_report_period = check_period(Configuration.config_struct.sampleperiod);} if (Configuration.config_struct.alarm_source[0] == Constant_Alarm) { sensor_report_period = check_period(Configuration.config_struct.alarmperiod);} if (Configuration.config_struct.alarm_source[0] >= enD_generaL_reporT) { sensor_report_period = check_period(Configuration.config_struct.sampleperiod);} repeater_verbose_mode = FALSE; report_now = FALSE; report_enabled = REPORT_DISABLED; /* start all periodic clocks */ secs_clock = SYS_GetSecs(); repeater_mac_clock = repeater_mac_clock + REPEATER_VERBOSE_PERIOD; heartbeat_clock = secs_clock + HEARTBEAT_PERIOD; adc_read_clock = secs_clock + ADC_READ_PERIOD; init_clock = secs_clock + INIT_PERIOD; sensor_report_clock = secs_clock + sensor_report_period; // network report clock inactivity_clock = secs_clock + inactivity_period; // watchdog timeout (device dep) show_configuration(); for (adc_channel = ADC_CHAN_0;adc_channel < CHANNEL_LEN;++adc_channel) { adc_response[adc_channel] = adc_channel;/* 0;*/ } adc_channel = ADC_CHAN_0; data_fresh = FALSE; time_ready = FALSE; #ifdef WATCHDOG_ENABLED WDTCN = 0x07; /* set the time delay for the watchdog */ WDTCN = 0x07; WDTCN = 0xa5; /* enable the watchdog timer */ watchdog_reset; /* reset the watchdog timer */ #endif len = 0; serial_ndx = 0; while (_peekc() != ~0) (void)_getkey(); /* empty the serial buffer */ #ifdef AUTO_ENABLE report_enabled = REPORT_ENABLED; #endif /*---------------------------------------------------------------------------*/ /* START OF FOREVER LOOP */ /*---------------------------------------------------------------------------*/ while(FOREVER) { if (SYS_Select(SYS_IO_RADIO_PKT)) { // packet processing ? mac_upcall(); } if (SYS_Timeout(&secs_clock, 1)) { // period glean bcast, delayed acks glean_timeout(10, role); } switch (Configuration.config_struct.operation_mode) { /************************* HUB MODE PROCESSING ******************************/ case PRIMARY_HUB_MODE: { /* --------------- if not initialized ------------------ */ if (report_enabled == REPORT_DISABLED) { /* create a boot message to send */ SensorData.ss.detector.sensor_type = Sensor_Init; for (i = 0;i < 6;++i) { SensorData.ss.s_id[i] = 0x00;} for (i = 0;i < 7;++i) { SensorData.ss.detector.d.d_array[i] = hub_boot_msg[i];} j = encode_msg(&SensorData.ss,ta); printds(j); ++report_enabled; } /* end processing report enabled = disabled */ /* -------------------- report pending ----------------------- */ if (report_enabled == REPORT_PENDING) { if (SYS_Select(SYS_IO_SERIAL_PKT)) { do { c = _getkey(); serial_buf[serial_ndx++] = c; if ((c == SLIP_CHAR) && (serial_ndx > 1)) { // now is the time to process your slip packet in serial_buf[0 ... i]. msg_type = process_msg_msg(serial_buf,serial_ndx); if (msg_type == 0x8001) { report_enabled = REPORT_ENABLED; } /* if message type is 8001 */ serial_ndx = 0; /* restart the index */ } /* if slip character */ } while (SYS_Select(SYS_IO_SERIAL_PKT)); /* do while */ } /* if character ready */ if (SYS_Timeout(&init_clock, INIT_PERIOD)) { goto watchdog_reboot; } } WATCHDOG(watchdog_reset); /* reset the watchdog timer */ break; } /* PRIMARY_HUB_MODE */ /************************ SENSOR MODE PROCESSING **************************/ case SENSOR_MODE: { if (_peekc() != ~0) { /* character present, process */ c = _getkey(); serial_buf[serial_ndx++] = c; if (c == ser_dev[0].d.framing) { switch (Configuration.config_struct.detector) { /* message received, decode */ /*---------------------------------------------------------------*/ case NO_SENSOR: { WATCHDOG(watchdog_reset); break; } /*---------------------------------------------------------------*/ case LUDLUM375: { inactivity_clock = SYS_GetSecs() + inactivity_period; format_ludlum_msg(serial_buf,&SensorData.ss.detector); SensorData.ss.detector.sensor_type = ludlum375_sensor; data_fresh = TRUE; /* we have fresh data */ /* this checks the message from the LUDLUM to clear an alarm mode if the alarm is cleared. if the alarm is cleared, the report period is set to the initial period, as defined in the initialization process */ if (Configuration.config_struct.alarm_source[0] >= LUD_starT) { if ((Configuration.config_struct.alarm_source[0] == LUD_High_Level) && ((SensorData.ss.detector.d.rad375.status & L_HALARM_STATUS) > 0x00)) { sensor_report_period = check_period(Configuration.config_struct.alarmperiod);} if ((Configuration.config_struct.alarm_source[0] == LUD_Low_Level) && ((SensorData.ss.detector.d.rad375.status & L_LALARM_STATUS) > 0x00)) { sensor_report_period = check_period(Configuration.config_struct.alarmperiod);} if ((Configuration.config_struct.alarm_source[0] == LUD_HighLow_Level) && ((SensorData.ss.detector.d.rad375.status & HILO_ALARM_STATUS) > 0x00)) { sensor_report_period = check_period(Configuration.config_struct.alarmperiod);} if ((SensorData.ss.detector.d.rad375.status & HILO_ALARM_STATUS) == 0x00) { sensor_report_period = check_period(Configuration.config_struct.sampleperiod);} } WATCHDOG(watchdog_reset); break; } /*---------------------------------------------------------------*/ case VPM: { inactivity_clock = SYS_GetSecs() + inactivity_period; for (i = 0; i < serial_ndx; ++i) {putchar(serial_buf[i]);} format_vpm_msg(serial_buf,serial_ndx,&SensorData.ss.detector); SensorData.ss.detector.sensor_type = VPM_sensor; data_fresh = TRUE; /* we have fresh data */ if ((Configuration.config_struct.alarm_source[0] == VPM_A_Value) && (SensorData.ss.detector.d.vpm.status == 'A')) { sensor_report_period = check_period(Configuration.config_struct.alarmperiod);} WATCHDOG(watchdog_reset); break; } /*---------------------------------------------------------------*/ case GID3: { inactivity_clock = SYS_GetSecs() + inactivity_period; format_gid3_msg(serial_buf,&SensorData.ss.detector); SensorData.ss.detector.sensor_type = GID3_sensor; data_fresh = TRUE; /* we have fresh data */ if ((Configuration.config_struct.alarm_source[0] == GID3_G_Bars) || (Configuration.config_struct.alarm_source[0] == GID3_GH_Bars)) { i = (Configuration.config_struct.alarm_source[1] >> 4) & 0x0f; j = (SensorData.ss.detector.d.gid3.display_bars >> 4) & 0x0f; if (j >= i) { sensor_report_period = check_period(Configuration.config_struct.alarmperiod); } } if ((Configuration.config_struct.alarm_source[0] == GID3_H_Bars) || (Configuration.config_struct.alarm_source[0] == GID3_GH_Bars)) { i = Configuration.config_struct.alarm_source[1] & 0x0f; j = SensorData.ss.detector.d.gid3.display_bars & 0x0f; if (j >= i) { sensor_report_period = check_period(Configuration.config_struct.alarmperiod); } } WATCHDOG(watchdog_reset); break; } /*---------------------------------------------------------------*/ case GRS: { inactivity_clock = SYS_GetSecs() + inactivity_period; SensorData.ss.detector.sensor_type = GRS_sensor; WATCHDOG(watchdog_reset); break; } } /* switch */ ts = SYS_GetTime(); SensorData.ss.timestamp.hours = ts->hours; SensorData.ss.timestamp.minutes = ts->minutes; SensorData.ss.timestamp.seconds = ts->seconds; SensorData.ss.timestamp.h_seconds = ts->h_seconds; serial_ndx = 0; } /* if (c == ser_dev[0].d.framing) */ if (SYS_Timeout(&heartbeat_clock, HEARTBEAT_PERIOD)) { SensorData.ss.detector.sensor_type = Board_Heartbeat; SensorData.ss.detector.d.tv.temperature = adc_response[ADC_BOARD_TEMP]; SensorData.ss.detector.d.tv.battvolts = adc_response[ADC_INPUT_VOLTAGE]; transmit(HB_MSG_TYPE); } if (SYS_Timeout(&inactivity_clock, inactivity_period)) { /* no serial input received for a long time; reset */ goto watchdog_reboot; } if (SYS_Timeout(&sensor_report_clock, SENSOR_REPORT_PERIOD)) { time_ready = TRUE; } if (((data_fresh) && (time_ready)) || (report_now)){ /* if ready to report */ transmit(EX_MSG_TYPE); /* send a message */ /* and disable all keys */ report_now = FALSE; data_fresh = FALSE; time_ready = FALSE; } break; } /* peekc() != ~0 */ /***************** ROUTING MODE PROCESSING ******************/ case ROUTING_MODE: { if (SYS_Select(SYS_IO_SERIAL)) { /* check for a space to enter verbose mode */ c = _getkey(); if (c == ' ') { ser_flush(); repeater_verbose_clock = SYS_GetSecs() + REPEATER_VERBOSE_PERIOD; repeater_verbose_mode = TRUE; gip_log = TRUE; } if (c == SER_ESCAPE) { ser_flush(); goto watchdog_reboot; } } if (repeater_verbose_mode == TRUE) { /* if the time ends, shut off the output */ if (SYS_Timeout(&repeater_verbose_clock, REPEATER_VERBOSE_PERIOD)) { repeater_verbose_mode = FALSE; gip_log = FALSE; } } /* check for repeater / mac inactivity */ if ((app_tx == mac_stats.tx) && (app_rx == mac_stats.rx)) { if (SYS_Timeout(&repeater_mac_clock, REPEATER_MAC_PERIOD)) { goto watchdog_reboot; } } else { app_tx = mac_stats.tx; app_rx = mac_stats.rx; repeater_mac_clock = SYS_GetSecs(); } WATCHDOG(watchdog_reset); break; } /***************** SECONDARY HUB MODE PROCESSING ******************/ case SECONDARY_HUB_MODE: { break; } /********************* DEFAULT PROCESSING ******************/ default: { printf("error, illegal mode!\n"); break; } } /* switch */ } /* forever */ } /*---------------------------------------------------------------------------*/ /* END OF FOREVER LOOP */ /*---------------------------------------------------------------------------*/ } /* main */ /****************************************************************************/ void transmit(u_char_t msg_type) { packetptr_t packet; struct radio_s *sp; enum GIP_Err_t err; u_char_t s_len; // length of packet in slip on serial port u_char_t packet_len,payload_len; // length of packet payload u_char_t c,i; if ((packet = mac_getbuf())) { sp = (struct radio_s *)((u_char_t *)packet->p + GIP_HDR_END); for (s_len = 0;s_len < 6;s_len++) { (SensorData.ss.s_id[s_len] = MAC_MY_UID.bytes[s_len]);} payload_len = encode_radio_data(msg_type,sp); packet_len = payload_len + GIP_HDR_END; if (payload_len > 0) { /* length > 0, data persent */ /* check the length, for over length */ //if (packet_len < MAC_MAX_LTH) { /* if not too long */ if (packet_len < GIP_PAYLOAD) { /* if not too long */ if (Configuration.config_struct.verbose >= SHOW_MESSAGES) { s_len = encode_msg(sp,ta); printds(s_len); } /* if showing all messages */ /* send the packet */ err = gip_send(packet, packet_len, (macid_t *)& MAC_ROOT_UID, GIPP_SUNSCREEN, suns_genPid++); } /* end if packet not too long */ else { /* else, packet is too long */ c = (payload_len / 100) + '0'; putchar(c); i = payload_len % 100; c = (i / 10) + '0'; putchar(c); c = (i % 10) + '0'; putchar(c); putchar(' '); c = (packet_len / 100) + '0'; putchar(c); i = packet_len % 100; c = (i / 10) + '0'; putchar(c); c = (i % 10) + '0'; putchar(c); putchar(' '); s_len = GIP_PAYLOAD; c = (s_len / 100) + '0'; putchar(c); i = s_len % 100; c = (i / 10) + '0'; putchar(c); c = (i % 10) + '0'; putchar(c); putchar(0x0a); putchar(0x0d); mac_free(packet); err = 0; } /* if over max length, post an error */ } /* payload greater than 0 */ } /* if the packet is real */ else { err = MACE_NO_PACKET;} if (err && Configuration.config_struct.verbose >= SHOW_ERRORS) { printf("tx1(" _bd_ ")/msg(" _bd_ ")", err, msg_type); if (err == GIPE_TABLE) {printf(" - no root known");} printf("!\n");} return;} /****************************************************************************/ void format_vpm_msg(u_char_t *buf,u_char_t len,struct detector_type *si) { _data u_vchar_t i=0,j=0,k=0,l=0,tuc; /* preset the data base */ for (i = 0; i < 4; ++i) { for (j = 0; j < 3; ++j) { si->d.vpm.reading[i][j] = 0x00;}} si->d.vpm.status = 0x00;; si->d.vpm.status = buf[0]; for (i = 1; ((i < len) && (buf[i] > ' ')); ++i) { if (buf[i] == ',') { k = (i - 1) / 7; j = 0; /* resync the key */ l = 0; } else if (buf[i] < ' ') {return;} /* if end of string */ else { /* not a delimiter */ tuc = buf[i] - '0'; if (j == 0) { si->d.vpm.reading[k][l] = tuc << 4;} else { si->d.vpm.reading[k][l++] += tuc;} j = (++j) % 2; } } return;} /****************************************************************************/ #define BCD_buf buf[i] - '0' void format_gid3_msg(u_char_t *buf,struct detector_type *s) { _data u_vchar_t i; for (i = 0;i < 10; ++i) {s->d.gid3.diagnostic_vals[i] = 0x00;} for (i = 0;i < 33; ++i) {s->d.gid3.IMS_vals[i] = 0x00;} i = buf[1] - '0'; i = i << 4; s->d.gid3.display_bars = i & 0xf0; s->d.gid3.display_bars |= ((buf[2] - '0') & 0x0f); s->d.gid3.states = (((buf[3] - '0') & 0x0f) << 4); s->d.gid3.states |= ((buf[4] - '0') & 0x0f); s->d.gid3.G_cs = (((buf[6] - '0') & 0x0f) << 4); s->d.gid3.G_cs |= ((buf[7] - '0') & 0x0f); for (i = 10; i < 29; ++i) { s->d.gid3.IMS_vals[i - 10] = buf[i];} s->d.gid3.sn[0] = buf[30]; s->d.gid3.sn[1] = buf[31]; s->d.gid3.sn[2] = buf[32]; for (i = 34; i < 29; ++i) { s->d.gid3.IMS_vals[i - 34] = buf[i];} return;} /****************************************************************************/ void format_grs_msg(u_char_t *buf,int l,struct detector_type *s) { _data u_vchar_t i=0; while ((buf[i] > ' ') && (i < l)) { s->d.grs.dummy[i] = 0x00;; } return;} /****************************************************************************/ void format_ludlum_msg(u_char_t *buf,struct detector_type *s) { u_char_t i=0,j=0,tuc; i = 0; j = 0; do { if ((isnumber(buf[i])) || (buf[i] == '.')) { buf[j++] = buf[i];} ++i; } while ((buf[i] != 0x0d) && (i < 20)); tuc = buf[l_radiation0] - '0'; s->d.rad375.radiation[0] = tuc << 4; tuc = buf[l_radiation1] - '0'; s->d.rad375.radiation[0] += tuc; tuc = buf[l_radiation2] - '0'; s->d.rad375.radiation[1] = tuc << 4; tuc = buf[l_radiation3] - '0'; s->d.rad375.radiation[1] += tuc; tuc = buf[l_radiation4] - '0'; s->d.rad375.radiation[2] = tuc << 4; s->d.rad375.radiation[3] = 0x00; s->d.rad375.status = 0x00; /* clear the status to start */ if (buf[l_status_audio] == '1') s->d.rad375.status |= L_AUDIO_STATUS; if (buf[l_status_hi_alarm] == '1') s->d.rad375.status |= L_HALARM_STATUS; if (buf[l_status_lo_alarm] == '1') s->d.rad375.status |= L_LALARM_STATUS; if (buf[l_status_overrange] == '1') s->d.rad375.status |= L_OVERRANGE_STATUS; if (buf[l_status_monitor] == '1') s->d.rad375.status |= L_MONITOR_STATUS; s->d.rad375.ecode = buf[l_errorcode] - '0'; /* check for any alarms */ /* if this system is in the SS1 mode, it checks for a monitor alarm with no errors posted. If this condition exists, the radiation report goes into an alarm mode, which is set by the define ALARM_REPORT_PERIOD. The boolean report_now is set, forcing an immediate report */ if (Configuration.config_struct.serialfmt == SS1_SIMULATION) { /* if error condition, set the rapid alart time and start now */ if ((((s->d.rad375.status & ~L_MONITOR_STATUS) & STATUS_MASK) > 0x00) || (s->d.rad375.ecode > 0x00)) { if (sensor_report_period != Configuration.config_struct.alarmperiod) { report_now = TRUE;} sensor_report_period = Configuration.config_struct.alarmperiod; } } /* end SS1 simulation */ return;} /****************************************************************************/ u_int16_t process_msg_msg(u_char_t *s,u_char_t len) { u_int16_t mtype; u_char_t i; //u_char_t i,j; mtype = 0; // fix unitialized variable compiler error for (i = 0; i < len; ++i) {putchar(s[i]);} putchar(0x0a); if (len > 17) { if ((s[13] == 'H') && (s[14] == 'U') && (s[15] == 'B') && (s[16] == 'I') && (s[17] == 'N') && (s[18] == 'I') && (s[19] == 'T')) { mtype = (s[11] << 8) + s[12]; SensorData.ss.timestamp.hours = SYS_HexClock.hours = s[7]; SensorData.ss.timestamp.minutes = SYS_HexClock.minutes = s[8]; SensorData.ss.timestamp.seconds = SYS_HexClock.seconds = s[9]; SensorData.ss.timestamp.h_seconds = SYS_HexClock.h_seconds = s[10]; i = encode_msg(&SensorData.ss,ta); printds(i); } } return(mtype);} /****************************************************************************/ /* Function to load data from a data collection structure into the primary */ /* data structure SENSORDATA. */ /****************************************************************************/ u_char_t encode_radio_data(u_char_t msg_type, struct radio_s *ds) { u_char_t i; u_char_t dec_len = 0; for (i = 0; i < 6; i++) {ds->s_id[i] = SensorData.ss.s_id[i];} ds->timestamp = SensorData.ss.timestamp; ds->detector.sensor_type = SensorData.ss.detector.sensor_type; if (msg_type == EX_MSG_TYPE) { /* process external sensor */ /* select the proper message type */ switch (Configuration.config_struct.detector) { case LUDLUM375: {dec_len = LUDLUM375_LEN;break;} case VPM: {dec_len = VPM_LEN;break;} case GID3: {dec_len = GID3_LEN;break;} case GRS: {dec_len = GRS_LEN;break;} default: { fault(0); // error, no detector but still sending msg return(0);} } /* end selecting sensor type */ } if (msg_type == HB_MSG_TYPE) {dec_len = TV_LEN;} /* process heartbeat message */ if (dec_len > 0) { /* length greater than zero, message real */ for (i = 0; i < dec_len; i++) { /* transfer the data */ ds->detector.d.d_array[i] = SensorData.ss.detector.d.d_array[i];} dec_len += sizeof(SYS_HexClock_t) + 8; } /* if the data length is gt zero, = message real */ return(dec_len);} //#ifdef _Old_Configuration /****************************************************************************/ void init_scratchpad(void) { FLSCL = 0x00; return;} /****************************************************************************/ u_vchar_t erase_scratchpad (void) { unsigned char _data *scratchpad_p; vint16_t addr; u_vchar_t i,retval=0xff; #ifndef unix intrmask_t s = splhigh(); /* disable all interrupts */ FLSCL = 0x01; PSCTL = 0x07; scratchpad_p = (unsigned char _data *)addr; *scratchpad_p = 0x00; PSCTL = 0x04; /* enable scratchpad read access */ FLSCL = 0x00; scratchpad_p = (unsigned char _data *)addr; for (i = 0; i < 128; i++) { if (*scratchpad_p != 0xff) { retval = 0x00;} } PSCTL = 0x00; /* disable all scratchpad access */ splx(s); /* restart the interrupts */ #else (void)i; (void)addr; (void) scratchpad_p; #endif return(retval);} /****************************************************************************/ u_char_t read_scratchpad (vint16_t addr) { u_vchar_t d; #ifndef unix PSCTL = 0x04; /* enable scratchpad read access */ d = (u_vchar_t _text *)addr; PSCTL = 0x00; /* disable all scratchpad access */ #else (void) addr; d = 0xff; #endif return(d);} /****************************************************************************/ void write_scratchpad (vint16_t addr,u_char_t d) { #ifndef unix intrmask_t s = splhigh(); FLSCL = 0x01; PSCTL = 0x05; *(u_vchar_t _data *)addr = d; PSCTL = 0x00; /* disable all scratchpad access */ FLSCL = 0x00; splx(s); #else (void) addr; (void) d; #endif return;} //#endif /****************************************************************************/ u_char_t check_configuration(void) { u_char_t c_good=TRUE; if (Configuration.config_struct.operation_mode >= ERROR_MODE) {c_good = FALSE;} else { if (Configuration.config_struct.verbose >= ENDOFMESSAGELEVELS) {c_good = FALSE;} else { if (Configuration.config_struct.xmitpower >= 4) {c_good = FALSE;} else { if ((Configuration.config_struct.PN_sequence < 2) || (Configuration.config_struct.PN_sequence > 7)) {c_good = FALSE;} else { // if ((Configuration.config_struct.serialfmt != 'A') && // (Configuration.config_struct.serialfmt != 'H')) {c_good = FALSE;} // else { if (Configuration.config_struct.operation_mode == SENSOR_MODE) { if (Configuration.config_struct.detector >= END_EXTERNAL_SENSOR_LIST) {c_good = FALSE;}} // } } } } } return(c_good);} /****************************************************************************/ void show_configuration(void) { u_vchar_t t; printf("\nCurrent Configuration\n"); printf("Mode: %s\n",mode_names[Configuration.config_struct.operation_mode]); printf("PN Sequence: "_bd_"\n",Configuration.config_struct.PN_sequence); printf("Display Level: %s\n",talk_levels_s[Configuration.config_struct.verbose]); printf("Serial format: %s\n",display_modes[Configuration.config_struct.serialfmt]); if (Configuration.config_struct.operation_mode == SENSOR_MODE) { printf("Detector type: %s\n", sensor_type[Configuration.config_struct.detector].name); printf(" Alarm Mode: "); switch (Configuration.config_struct.detector) { case NO_SENSOR: { printf(" No Sensor Specified\n"); break;} case LUDLUM375: { printf("%s\n",LUD_Alarms[Configuration.config_struct.alarm_source[0]].name); break;} case GRS: { printf(" GRS Sensor not Available"); break;} case VPM: { printf("%s\n",VPM_Alarms[Configuration.config_struct.alarm_source[0]].name); break;} case GID3: { if ((Configuration.config_struct.alarm_source[0] == GID3_G_Bars) || (Configuration.config_struct.alarm_source[0] == GID3_GH_Bars)) { t = Configuration.config_struct.alarm_source[1] >> 4; printf(_bd_" %s\n",t,GID3_Alarms[GID3_G_Bars].name); } else if ((Configuration.config_struct.alarm_source[0] == GID3_H_Bars) || (Configuration.config_struct.alarm_source[0] == GID3_GH_Bars)) { t = Configuration.config_struct.alarm_source[1] & 0x0f; printf(_bd_" %s\n",t,GID3_Alarms[GID3_H_Bars].name); } else { printf("%s\n",GID3_Alarms[Configuration.config_struct.alarm_source[0]].name); } break;} } printf("Sample period:%u\n", Configuration.config_struct.sampleperiod); printf("Alarm period:%u\n", Configuration.config_struct.alarmperiod);} printf("Transmit power: " _bd_ "\n", Configuration.config_struct.xmitpower); printf("Root ID: "); showmac(Configuration.config_struct.hub_id); putchar(0x0d); putchar(0x0a); printf("Module ID: "); showmac(MAC_MY_UID.bytes); putchar(0x0d); putchar(0x0a); putchar('\n'); return;} /****************************************************************************/ void showmac(u_vchar_t *s) { u_vchar_t i,c; for (i = 0; i < 6; ++i) { if (i > 0) {putchar(':');} c = highnibble(s[i]); putchar(c); c = lownibble(s[i]); putchar(c);} return;} /****************************************************************************/ void userif (void) { u_vchar_t i,t; /*--------------------Get operation mode from user ------------------------*/ do { printf("Mode: "); for (i = 0; i < ERROR_MODE; ++i) { printf(_bu_" .. %s\n ",i,mode_names[i]); } Configuration.config_struct.operation_mode = getnum(); putchar('\n'); } while (Configuration.config_struct.operation_mode >= ERROR_MODE); /*------------------------ determine PN Sequence --------------------------*/ do { printf("\nPN Sequence [2 - 7]: "); // for (i = 0; i < END_EXTERNAL_SENSOR_LIST; ++i) { // printf(_bu_ " .. %s\n ",i,sensor_type[i].name); // } // printf("Sensor type [1-"_bd_"]: ",END_EXTERNAL_SENSOR_LIST-1); Configuration.config_struct.PN_sequence = getnum(); putchar('\n'); } while ((Configuration.config_struct.PN_sequence <= 1) || (Configuration.config_struct.PN_sequence >= 8)); /*-------------------------- Get display type -----------------------------*/ do { printf("\nDisplay: "); for (i = 0; i < ENDOFMESSAGELEVELS; ++i) { printf(_bu_" .. %s\n ",i,talk_levels_s[i]); } Configuration.config_struct.verbose = getnum(); putchar('\n'); } while (Configuration.config_struct.verbose >= ENDOFMESSAGELEVELS); // Get serial format from user do { printf("\nSerial format:"); for (i = 0; i < END_OUTPUT_LIST; ++i) { printf(_bu_ " .. %s\n ",i,display_modes[i]); } Configuration.config_struct.serialfmt = getnum(); putchar('\n'); } while (Configuration.config_struct.serialfmt >= END_OUTPUT_LIST); getid( "\nHub Node Address: ", (macpad_t *) Configuration.config_struct.hub_id); if (Configuration.config_struct.operation_mode == SENSOR_MODE) { // Get detector type from user do { printf("\nSensor: "); for (i = 0; i < END_EXTERNAL_SENSOR_LIST; ++i) { printf(_bu_ " .. %s\n ",i,sensor_type[i].name); } // printf("Sensor type [1-"_bd_"]: ",END_EXTERNAL_SENSOR_LIST-1); Configuration.config_struct.detector = getnum(); putchar('\n'); } while (Configuration.config_struct.detector >= END_EXTERNAL_SENSOR_LIST); switch (Configuration.config_struct.detector) { /* select alarm mode */ case NO_SENSOR: {break;} case LUDLUM375: { do { printf("\nAlarm mode: "); for (i = 0; i < LUD_enD; ++i) { printf(_bu_ " .. %s\n ",i,LUD_Alarms[i].name); } Configuration.config_struct.alarm_source[0] = getnum(); putchar('\n'); } while (Configuration.config_struct.alarm_source[0] >= LUD_enD); break;} case VPM: { do { printf("\nAlarm mode: "); for (i = 0; i < VPM_enD; ++i) { printf(_bu_ " .. %s\n ",i,VPM_Alarms[i].name); } Configuration.config_struct.alarm_source[0] = getnum(); putchar('\n'); } while (Configuration.config_struct.alarm_source[0] >= VPM_enD); break;} case GID3: { do { printf("\nAlarm mode: "); for (i = 0; i < GID3_enD; ++i) { printf(_bu_ " .. %s\n ",i,GID3_Alarms[i].name); } Configuration.config_struct.alarm_source[0] = getnum(); putchar('\n'); } while (Configuration.config_struct.alarm_source[0] >= GID3_enD); Configuration.config_struct.alarm_source[1] = 0x00; if ((Configuration.config_struct.alarm_source[0] >= GID3_G_Bars) || (Configuration.config_struct.alarm_source[0] >= GID3_GH_Bars)) { do { printf("\nG bar counts: "); t = getnum(); putchar('\n'); } while (t > 8); Configuration.config_struct.alarm_source[1] = ((t << 4) & 0xf0); } if ((Configuration.config_struct.alarm_source[0] >= GID3_H_Bars) || (Configuration.config_struct.alarm_source[0] >= GID3_GH_Bars)) { do { printf("\nH bar counts: "); t = getnum(); putchar('\n'); } while (t > 8); Configuration.config_struct.alarm_source[1] |= (t & 0x0f); } /* if using G and/or H bar counts */ break;} case GRS: {break;} default: {break;} } // Get sample period from user printf("\nSample period [secs]: "); Configuration.config_struct.sampleperiod = check_period(getnum()); putchar('\n'); // printf("%u\n",Configuration.config_struct.sampleperiod); // Get alarm period from user printf("\nAlarm period [secs]: "); Configuration.config_struct.alarmperiod = check_period(getnum()); putchar('\n'); // printf("%u\n",Configuration.config_struct.alarmperiod); } /* end of if sensor only */ // Get transmit power level from user do { printf("\nXmit power [0-3]: "); Configuration.config_struct.xmitpower = getnum(); putchar('\n'); // printf(_bd_ "\n",Configuration.config_struct.xmitpower); } while (Configuration.config_struct.xmitpower > 3); printf("\n"); show_configuration(); printf("\n=== saving configuration ==\n"); // erase_scratchpad (); /* prepare the scratchpad for writing */ #ifndef unix FLASH_EraseScratch(0x0000); for (i = 0; i < Config_Len; ++i) { // write_scratchpad ((vint16_t) i,Configuration.config_string[i]); FLASH_WriteScratch(i,Configuration.config_string[i]); } #endif putchar('\n'); ser_flush(); return;} /****************************************************************************/ u_char_t input[12]; int_t getnum(void) { char_t num = 0; char_t sign = 1; u_char_t lth; u_char_t i; lth = ser_gets(input, sizeof(input)); for (i = 0; i < lth; i++) { switch(input[i]) { case '-': sign = -sign; case '+': break; default: num = num * 10 + (input[i] - '0'); break; } } num *= sign; return(num); } /****************************************************************************/ void getid(textptr_t string, macpad_t *id) { u_char_t i; u_char_t lth; u_char_t c; ser_showmac(string, id->bytes); printf("? > "); lth = ser_gets(input, sizeof(input)); for (i = 0; i < lth/2; i++) { c = Downcase(input[i*2]); c = AsciiHexToBinary(c); id->bytes[i] = (c) << 4; c = Downcase(input[i*2+1]); c = AsciiHexToBinary(c); id->bytes[i] |= c; } } /****************************************************************************/ char getuchar(void) { char inchar,wchar=0x00; do { inchar = _getkey(); if (isprintable(inchar)) { if (lc_char(inchar)) {wchar = toupper(inchar);} else {wchar = inchar;} printf("%c",inchar); } } while (inchar != '\r'); return(wchar);} /****************************************************************************/ /****************************************************************************/ char Atohex (unsigned char y) { y = y - ((y > '9')?0x37:0x30); return(y);} /****************************************************************************/ char hextoA (unsigned char y) { y = y + ((y > 9)?0x37:0x30); return(y);} /****************************************************************************/ char highnibble (char x) { x = ((x >> 4) & 0x0f); return(hextoA(x));} /****************************************************************************/ char lownibble (char x) { x = (x & 0x0f); return(hextoA(x));} /****************************************************************************/ /****************************************************************************/ #define ENCODE_ESCAPE(a) \ if (a == SLIP_CHAR) {s[j++] = ESCAPE_CHAR;s[j++] = ESCAPED_EOM;} \ else if (a == ESCAPE_CHAR) {s[j++] = ESCAPE_CHAR;s[j++] = ESCAPED_ESCAPE;} \ else s[j++] = a /****************************************************************************/ /****************************************************************************/ u_char_t encode_msg(struct radio_s *sd,u_char_t *s) { u_char_t i,j,k,m=0; union {int ti;u_char_t tc[2];}t; switch (sd->detector.sensor_type) { /* determine message length */ case ludlum375_sensor: {k = LUDLUM375_LEN;m = 0;break;} case GRS_sensor: {k = GRS_LEN;m = 0;break;} case VPM_sensor: {k = VPM_LEN;m = 0;break;} case GID3_sensor: {k = GID3_LEN;m = 0;break;} case Board_Heartbeat: {k = TV_LEN;m = 0;break;} case Sensor_Init: {k = 7;m = 1;break;} default: {k = 0;m = 0;break;} } j = 0; /* start the message */ s[j++] = SLIP_CHAR; /* sensor IDs */ // if (m == 0) for (i = 0; i < 6; i++) {ENCODE_ESCAPE(sd->s_id[i]);} // else // for (i = 0; i < 6; i++) {s[j++] = 0x00;} /* LQ value */ if (m == 0) { ENCODE_ESCAPE(0x00);} else { s[j++] = 0x00;} /* timestamp */ ENCODE_ESCAPE(sd->timestamp.hours); ENCODE_ESCAPE(sd->timestamp.minutes); ENCODE_ESCAPE(sd->timestamp.seconds); ENCODE_ESCAPE(sd->timestamp.h_seconds); /* message type */ t.ti = sd->detector.sensor_type; ENCODE_ESCAPE(t.tc[0]); ENCODE_ESCAPE(t.tc[1]); /* sensor data */ switch (sd->detector.sensor_type) { /* handle special cases */ case GID3_sensor: { /* ----- DISPLAY BARS & STATES ------- */ i = ((sd->detector.d.gid3.display_bars >> 4) & 0x0f) + '0'; ENCODE_ESCAPE(i); i = (sd->detector.d.gid3.display_bars & 0x0f) + '0'; ENCODE_ESCAPE(i); i = ((sd->detector.d.gid3.states >> 4) & 0x0f) + '0'; ENCODE_ESCAPE(i); i = (sd->detector.d.gid3.states & 0x0f) + '0'; ENCODE_ESCAPE(i); i = ((sd->detector.d.gid3.G_cs >> 4) & 0x0f) + '0'; ENCODE_ESCAPE(i); i = (sd->detector.d.gid3.G_cs & 0x0f) + '0'; ENCODE_ESCAPE(i); /* ----- DIAGNOSTIC VALUES ------- */ for (j = 0; j < 19; ++j) { ENCODE_ESCAPE(sd->detector.d.gid3.diagnostic_vals[j]);} /* ----- SERIAL NUMBER ------- */ for (j = 0; j < 3; ++j) { ENCODE_ESCAPE(sd->detector.d.gid3.sn[0]);} /* ----- IMS VALUES ------- */ for (j = 0; j < 70; ++j) { ENCODE_ESCAPE(sd->detector.d.gid3.IMS_vals[j]);} break;} default: { for (i = 0; i < k; i++) {ENCODE_ESCAPE(sd->detector.d.d_array[i]);} break;} } /* end of creating display */ /* CRC */ t.ti = crc_sum16(s,j); ENCODE_ESCAPE(t.tc[0]); ENCODE_ESCAPE(t.tc[1]); /* end the message */ s[j++] = SLIP_CHAR; s[j] = 0x00; return(j);} /****************************************************************************/ u_char_t encode_repeater_msg(char *s,u_char_t l) { u_char_t i,j; j = 0; s[j++] = '['; for (i = 0; i < 6; i++) { s[j++] = highnibble(l); s[j++] = lownibble(l);} s[j++] = ']'; s[j++] = ' '; s[j++] = '['; for (i = 0; i < 6; i++) { s[j++] = highnibble(l); s[j++] = lownibble(l);} s[j++] = ']'; s[j++] = ' '; s[j++] = highnibble(l); s[j++] = lownibble(l); s[j++] = 0x0d; s[j++] = 0x0a; s[j++] = 0x00; return(j);} /****************************************************************************/ #ifdef a1 void encode_tv_msg(struct radio_s *sd,char *s) { u_char_t j,sum; union {int ti;u_char_t tc[2];}t; /* temperature */ t.ti = sd->tv.temperature; s[j++] = highnibble(t.tc[0]); s[j++] = lownibble(t.tc[0]); sum += t.tc[0]; s[j++] = highnibble(t.tc[1]); s[j++] = lownibble(t.tc[1]); sum += t.tc[1]; /* battery volts */ t.ti = sd->tv.battvolts; s[j++] = highnibble(t.tc[0]); s[j++] = lownibble(t.tc[0]); sum += t.tc[0]; s[j++] = highnibble(t.tc[1]); s[j++] = lownibble(t.tc[1]); sum += t.tc[1]; return;} #endif /****************************************************************************/ #ifdef OldSS1Junque void encode_SS1_msg(struct radio_s *sd,char *s) { u_char_t i,j,sum; union {unsigned int ti;u_char_t tc[2];}t; j = 0; /* message type */ s[j++] = highnibble(sd->sensor_type); s[j++] = lownibble(sd->sensor_type); sum = sd->sensor_type; //sum += (s[j++] = ' '); /* *** DEBUG STATEMENT *** */ /* sensor IDs */ for (i = 0; i < 6; i++) { s[j++] = highnibble(sd->s_id[i]); s[j++] = lownibble(sd->s_id[i]); sum += sd->s_id[i]; } //sum += (s[j++] = ' '); /* *** DEBUG STATEMENT *** */ t.ti = sd->timestamp; s[j++] = highnibble(t.tc[0]); s[j++] = lownibble(t.tc[0]); sum += t.tc[0]; s[j++] = highnibble(t.tc[1]); s[j++] = lownibble(t.tc[1]); sum += t.tc[1]; //sum += (s[j++] = ' '); /* *** DEBUG STATEMENT *** */ switch (sd->sensor_type) { /* ---------------------- radiation --------------------- */ case RAD_MSG_TYPE: { for (i = 0; i < 4; i++) { s[j++] = highnibble(sd->detector.d.rad375.radiation[i]); s[j++] = lownibble(sd->detector.d.rad375.radiation[i]); sum += sd->detector.d.rad375.radiation[i]; } //sum += (s[j++] = ' '); /* *** DEBUG STATEMENT *** */ /* status */ s[j++] = highnibble(sd->detector.d.rad375.status); s[j++] = lownibble(sd->detector.d.rad375.status); sum += sd->detector.d.rad375.status; //sum += (s[j++] = ' '); /* *** DEBUG STATEMENT *** */ /* error code */ s[j++] = highnibble(sd->detector.d.rad375.ecode); s[j++] = lownibble(sd->detector.d.rad375.ecode); sum += sd->detector.d.rad375.ecode; break;} /* --------------------- temp/voltage --------------------- */ case TV_MSG_TYPE: { /* time index */ t.ti = sd->tv.battvolts; s[j++] = highnibble(t.tc[0]); s[j++] = lownibble(t.tc[0]); sum += t.tc[0]; s[j++] = highnibble(t.tc[1]); s[j++] = lownibble(t.tc[1]); sum += t.tc[1]; break;} default: { break;} } /* end of processing message types */ //sum += (s[j++] = ' '); /* *** DEBUG STATEMENT *** */ s[j++] = highnibble(sum); s[j++] = lownibble(sum); s[j++] = 0x0d; s[j++] = 0x00; return;} #endif /****************************************************************************/ void printds(u_char_t len) { u_char_t i,c; if (Configuration.config_struct.serialfmt == SS2_ASCII) { for (i = 0;i < len; ++i) { c = highnibble(ta[i]); putchar(c); c = lownibble(ta[i]); putchar(c);}} // printf(_bx_,ta[i]);} if (Configuration.config_struct.serialfmt == SS2_BINARY) { for (i = 0;i < len; ++i) {putchar(ta[i]);}} // printf("%c",ta[i]);} if (Configuration.config_struct.serialfmt == SS2_ASCII) { printf("\n");} return;} /****************************************************************************/ secs16_t check_period(secs16_t period) { if (period < SS2_MIN_PERIOD) { period = SS2_MIN_PERIOD; printf("invalid config (sample period), setting to %d.\n",SS2_MIN_PERIOD); } return(period);} /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ /****************************************************************************/ /****************************************************************************/