Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/15/03 08:16
Read: times


 
#60610 - RE: Previously Unsolved problem. Using Modem
Responding to: ???'s previous message
I decided to look at the code. Apart from gems like:

" The purpose of this function is defining the modem functions"
Well that tells us a lot! What are the modem functions and what are you trying to achieve??? Read a book called 'code complete' to advise how to comment code.

In the main procedure, you test port1== 0x7f to decide whether to hang up. I dare say you want to test the transition of p1.7 to determine when to hang up.

A generic solution here would be to use a 'finite state machine'. If you don't know what one is - find out!

put simply:

char modem_state = 0; //to be really slick - use enums

switch(modem_state)
{
case 0: //send modem init
send_modem("AT.........."); // or whatever
modem_state = 1;
break;
case 1: //test p1.7 high for hangup
if (port1 & 0x80)
{
send_modem("ATH");
modem_state = 2;
}
break;
case 2: //test for p1.7 low to continue
if (!(port1 & 0x80))
modem_state = 1;
break;
} //end switch

Each 'state' or case does a particular operation and depending on inputs, selects the next state. Add your own meat and vegetables to my flavour sachet for a wonderful meal.

Also, remember that the modem doesn't respond instantaneously - some delays will be required. After sending the ATH the modem will need a few hundred milliseconds to do what you want. If after this time the modem hasn't responded you can either retry or fail the operation. Thus the beauty of the state machine. To get really smart you could execute the state machine every 100mS.

Try doing a bit of thinking to solve your problem in future and don't expect the internet to save your lazy ass. Merry Christmas!





List of 23 messages in thread
TopicAuthorDate
Previously Unsolved problem. Using Modem            01/01/70 00:00      
   RE: Previously Unsolved problem. Using M            01/01/70 00:00      
   RE: Previously Unsolved problem. Using M            01/01/70 00:00      
      RE: Previously Unsolved problem. Using M            01/01/70 00:00      
   RE: Previously Unsolved problem. Using Modem            01/01/70 00:00      
      got two points. Checking them...            01/01/70 00:00      
         Wrong cable?            01/01/70 00:00      
            RE: Wrong cable?            01/01/70 00:00      
               RE: Wrong cable?            01/01/70 00:00      
               RE: Wrong cable?            01/01/70 00:00      
               Back to Basics            01/01/70 00:00      
         RE: got two points. Checking them...            01/01/70 00:00      
         RE: got two points. Checking them...            01/01/70 00:00      
            line termination character            01/01/70 00:00      
               RE: line termination character            01/01/70 00:00      
         RE: got two points. Checking them...            01/01/70 00:00      
   why not eliminate            01/01/70 00:00      
      RE: why not eliminate            01/01/70 00:00      
   RE: Previously Unsolved problem. Using Modem            01/01/70 00:00      
   RE: Previously Unsolved problem. Using Modem            01/01/70 00:00      
      RE: Previously Unsolved problem. Using Modem            01/01/70 00:00      
         RE: Previously Unsolved problem. Using Modem            01/01/70 00:00      
   Once youve got it going...            01/01/70 00:00      

Back to Subject List