/* This program is designed to act as a master controller to send the time to one EM1000, pause, then send the time to a different EM1000. Multi EM1000 Modem Application Copyright (c) 1999, Z-World Engineering A BL1700 controller controls one EM1000 which alternately sends serial messages to another EM1000. The two receiving EM1000s should be configured for passive listening via the LISTEN.BAT batch file. Make sure that each is configured with a unique IP address suitable for your network. Also make sure to modify the IP addresses in this program to match the ones you've selected. The master EM1000 should be configured minimally as follows (additional commands might be desired to control the flow of data from the master EM1000 to the slave EM1000s): baud 19200 configmode gpio connect request The RS-232 serial port of the BL1700 (serial port Z0) should be connected to the COM1/RS232 port of the EM1000. Two additional lines need to be added. One connects ground of the BL1700 to ground of the EM1000. The other connection digital output pin 0 (Bank B) to the CTL input of the EM1000. If available, code for the Bl1700 should be compiled and debugged using the SIB2 to the core module and a serial cable from H12 connecting to the EM1000. If not available, simply downloading the code from the PC prior to switching the serial cable to the EM1000 should be sufficient. */ // Author: Richard Jensen Zworld Technical Support // Revision history: 01/07/00 1.0.2 multi_ip.c modified to send time through a BL1700 #use "EM1000.LIB" void send(char *pcName, char *wCount); void em_Mode(int bCmd); void main( void) { //*********************************************** Board & variables setup ***************************************************** char Lead[100]; //working buffer #1 char End[] = "The time will now be sent to Allan's EM1000.\r"; //Supplemental message char End2[] = "The time will now be sent to Richard's EM1000.\r"; //Supplemental message char Combo[128]; //Buffer to concat to struct tm sTM; //Structure to hold time variables /* manually set time as needed manually set time as needed manually set time as needed sTM.tm_year = 00; // Date = Sep 8, 1999 sTM.tm_mon = 01; sTM.tm_mday = 07; sTM.tm_hour = 9; // Time = 14:35:00 pM sTM.tm_min = 01; sTM.tm_sec = 00; while (tm_wr ( &sTM )); // Write New Time to RTC */ //************************* Set up message to be sent ***************************** emInit (); while(1) { memset(Combo, '\0', sizeof Combo); while(tm_rd (&sTM)); //Read RTC values retry if errors sprintf(Lead, "The time is %02d:%02d hours. \0", sTM.tm_hour, sTM.tm_min); strcat(Combo, Lead); memcpy(&Combo[strlen(Lead)], End, strlen(End)); send ( "10.10.6.10",Combo ); emDelay(1000*60); // delay for 60 seconds memset(Combo, '\0', sizeof Combo); while(tm_rd (&sTM)); //Read RTC values retry if errors sprintf(Lead, "The time is %02d:%02d hours. \0", sTM.tm_hour, sTM.tm_min); strcat(Combo, Lead); memcpy(&Combo[strlen(Lead)], End2, strlen(End)); send ( "10.10.6.20",Combo); emDelay(1000*60); // delay for 60 seconds } }//****************************** End of Main ******************************** void send(char *pcName, char *wCount) { if (emRemoteName ( pcName )) if (emOpen (0)) { emDelay ( 500 ); emPrintf ( "%s \r",wCount ); emDelay ( 500 ); emClose (); } }//***************************** End of send ******************************** void em_Mode(int bCmd) { //outport ( DRV1,(bCmd?0xFF:0x00) ); re-define for use on a bl1700 bank b pin #0 outport(0x4100, (bCmd?0x01:0x00) ); }//**************************** End of modified em_Mode *********************