( Index )
Month

Brief Information about the January 2001 CSIG Meeting

WinHay32 --- Windows 32 Bit Hayes Modem Utility

3rd Tuesday of the month. 7:30PM - C/C++ Group, SPRS

Output Sample

Welcome to the C++ Users Group. This group is a "Special Interest Group" of the ACGNJ devoted to discussing programming languages in general and C, C++, and C++ for Windows programming in particular. Each month a small but hopefully useful program (complete with source code) is presented for discussion.

Win Hayes 32 is a 32-bit reincarnation of a program that I presented about five years ago. The basic idea of the program is to send command strings to a modem and then decode the results that the modem sends back. For example, if the modem sends back an L3, it means that the speaker volume is set on high.

The program is now a 32-bit visual C++ utility using Microsoft's MFC, foundation classes. It also uses a serial class developed by Tom Archer and Rick Leinecker.

At the meeting on Tuesday night we will be discussing both the Serial class, source code included, and the application as well as other serial communication topics.


SAMPLE CODE
===========
void HayView::OnHayStart() 
{
    char lpBuffer[500];
    char lpLine[500];
    static char command[] = ”AT&V\r”;      int i, j, idx, count;

    CListCtrl &LC = GetListCtrl();
    Top = 1 + LC.InsertItem(LC.GetItemCount(), "AT&V  Data ->>>>>>");
    CSerial serial;

    if (!serial.Open(GetDocument()->port, 2400))
        {
        AfxMessageBox(&Failed to open port!&);
        return;
        }

    count = serial.SendData(command, strlen(command));
    idx=0; lpLine[0] = 0;
    GetDocument()->SetModifiedFlag();

    for(i=0; i<50; i++,Sleep(100)) // Poll for so many 0.1 second periods
        {
        if (serial.ReadDataWaiting())
            {
            count = serial.ReadData(lpBuffer, 500);
            for (j=0; j<count; j++)
                {
                switch (lpBuffer[j])
                    {
                    case 0:
                    case '\r':  break;;

                    case '\n':  Display(lpLine); idx=0; lpLine[0]=0; break;

                    default:    lpLine[idx++]=lpBuffer[j]; lpLine[idx]=0;
                                if (idx >= 499) // prevent overflow
                                    {
                                    Display(lpLine); idx=0; lpLine[0]=0;
                                    }
                    }
                }
            }
        }
    if (idx > 0) Display(lpLine);   // handle leftovers
}

"Random Access" questions start at 7:30 Tuesday night.

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page