Listing 1-The CH2124 requires the pacing of each input character. I found that the printf function spits the characters out too fast. 
The code works despite the lack of handshake message handling. I ignored the messages from the CH2124 and used long delays to 
allow the CH2124 to digest the commands and send its handshake messages.


#include <16F876.h>
#include 
#device PIC16F876 *=16
#include 
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#use delay(clock=20000000)
#use rs232(baud=2400, xmit=PIN_C6, rcv=PIN_C7)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT,PUT
char const sendit_string[] = {"@TDM1"};
char const endmsg_string[] = {0x0D,0x2E,0x0D};  //CR . CR
char const crlf_string[] = {0x0D,0x0A};        //CR, LF
char message_string[25];
int8 portal_bits;
#define  lobby_door     0x01
#define  lobby_window   0x02
#define  patio_door     0x04
#define  patio_window   0x08
main()
{
//General housekeeping stuff
   int8 i;
   PORTA = 0xFD;		  
   PORTB = 0x20;		   
   PORTC = 0x80;        
   SET_TRIS_A(0x00);		
   SET_TRIS_B(0x00);    
   SET_TRIS_C(0x80);		
   ADCON1 = 0x06;		
   ADCON0 = 0;
//Your code would come up with the portal_bits value portal_bits = 	         	lobby_door;. Build the message depending on the sensor input bits
   	switch(portal_bits)
   {
      case lobby_door:
         strcpy(message_string,"@TM1=lobby door is open  ");
         break;
      case lobby_window:
         strcpy(message_string,"@TM1=lobby window is open");
         break;
      case patio_door:
         strcpy(message_string,"@TM1=patio door is open  ");
         break;
      case patio_window:
         strcpy(message_string,"@TM1=patio window is open");
         break;
   }				//Pace each character at 25 ms intervals
   delay_ms(5000);
   for(i=0;i<25;++i)
   {
   putc(message_string[i]);    //Store the email message
   delay_ms(25);
   }
   for(i=0;i<3;++i)
   {
   putc(endmsg_string[i]);
   delay_ms(25);
   }
   delay_ms(10000);
   for(i=0;i<5;++i)
   {
   putc(sendit_string[i]); 	//Send the email message
   delay_ms(25);
   }   
   for(i=0;i<2;++i)
    {
     putc(crlf_string[i]);
     delay_ms(25);
   }   
   while(1);
}