/* 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. The controller used in this sample was the BL1500 Multi EM1000 Modem Application Copyright (c) 1999, Z-World Engineering 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 BL1500 (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 BL1500 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 Bl1500 should be compiled and debugged using the SIB2 and a serial cable from H2 connecting to the EM1000. If not available, simply download 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 BL1500 #use EM1000.LIB //#use vdriver.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 = 24; sTM.tm_hour = 15; // Time = 14:35:00 pM sTM.tm_min = 45; sTM.tm_sec = 00; while (tm_wr ( &sTM )); // Write New Time to RTC */ //************************* Set up message to be sent ***************************** emInit (); //Standard z0232 serial send/recv 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*30); // delay for 30 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*30); // delay for 30 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 bl1500 pin #2 on H1 (not the protorype board) //Set pins 2-9 for output operations resPIOCA2(0xff); // 8 pins. Sets all to low has the effect of 00000000 on pins 2-9 resPIODA2('\B00000000'); //De-activate data lines on pins 2-9 if(bCmd == 0) { setPIODA2('\B00000001'); //Turn on pins 2 resPIODA2('\B11111110'); } else { //Turn off pin 2 setPIODA2('\B11111110'); //The best method here is to do res function 1st, setting the bits the way you resPIODA2('\B00000001'); //want active with a 1 then do the set function with bit complements if setting less then all } }//**************************** End of modified em_Mode *********************