A. Singlechip expansion module program design
Main program initializes serial port by InitSerial () and
some system parameters, after completing these, then
inquires the status of interface ports with sensors every 0.5
seconds. When any sensor alarms, the corresponding port
status changes into low level. Main program detects alarm
information, then calls sending alerts data function
SendSensor (). Alarm data uses "# $#" as the data
head .Behind content is sensor serial number, 1 for infrared,
2 for smoke, 3 for gas. Main program of expansion module
and transmit data flow chart are as shown in figure 4.