yeah,
this works in C++ also, simpley create a filestream to the correct COM port.
you should always leave a suitable timeout so that the modem doesn't get confused. ie, has time to dial the number before hanging up.
#include <fstream>
#include <time.h> //for sleep function to give a nice timeout
void main() {
int phonenumber = 1234555 ;
ostream modem("COM1:") ; //opens the stream
modem << "ATZ\n" ; //reset modem
modem.flush() ; //flush the buffer
modem << "ATH1\n" ; //take modem off-hook (picking phone up)
modem.flush() ;
modem << "ATC\n" ; //turn off modem carrier
modem.flush() ;
modem << "ATDT" << phoneNumber << "\n" ; //dial number
modem.flush() ;
Sleep(100) ;
modem << "ATH0\n" ; //back on-hook
modem.flush() ;
}




Reply With Quote