doubt

hi!
i got so much information from the sites which u have given.i am
developing a software for billing.we have a card that detects
16khz cycle.nowi am able to capture DSR level.but i am unable to
stop the processing when the signal stops.also i am unable to try
it out using multihtreading.below is the code.can u please out the
error.
regards
Asha Angadi
Conevergent Technologies
Switching R&D
ITI Limited
Bangalore

#include<stdio.h>
#include<conio.h>
#include<windows.h>

#define STATUS_CHECK_TIMEOUT 20
#define INTER_SAMPLE_DELAY 5
#define MAX_SAMPLES 20
#define MIN_AUTHENTIC_VALUE (MAX_SAMPLES/2)
#define INTER_PULSE_GUARD_BAND 2800

HANDLE hComp,hEvent;
DCB dcb;
DWORD dwEvtMask,dwModemState;
bool fdsr;
float bill;
int SampleCount = 0;
int dsrCount = 0;
int Tariff_Count;
int Misses,success;
bool Changed;
void main()
{

hComp= CreateFile( “com1”,GENERIC_READ |
GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,0);
if(hComp == INVALID_HANDLE_VALUE)
{
printf(“error”);
}
if(!GetCommState(hComp,&dcb))
{
printf(“error%d”,GetLastError());
}
dcb.BaudRate = 9600;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;

success = SetCommState(hComp,&dcb);
if(!success)
{
printf(“error”);
// return false;
}

success = SetCommMask(hComp,EV_CTS | EV_DSR);
if(!success)
{
printf(“error”);
}

hEvent = CreateEvent(NULL,FALSE,FALSE,NULL);
if(WaitCommEvent(hComp,&dwEvtMask,NULL))
{
if(dwEvtMask & EV_DSR)
{
fdsr = true;
}
}
fdsr = false;
while(1)
{
if(success)
{

for(SampleCount = 0; SampleCount<(MAX_SAMPLES)/2;
SampleCount++)
{
if(!GetCommModemStatus(hComp,&dwModemState))
{
printf(“error”);
}
// fdsr = GetCommModemStatus(hComp,&dwModemState);
fdsr = MS_DSR_ON & dwModemState;
if(fdsr)
{
dsrCount++;
}
}
}

if(dsrCount>MIN_AUTHENTIC_VALUE)
{
Tariff_Count++;
Sleep(INTER_PULSE_GUARD_BAND);
Changed = true;
}
else
{
Misses++;
Changed = true;
}
bill = Tariff_Count * 1.29;
printf(“%f\n”,bill);
//printf(“\t%d”,Tariff_Count);
}
printf(“\t%d”,Tariff_Count);
}

__________________________________________________________
Give your Company an email address like
ravi @ ravi-exports.com. Sign up for Rediffmail Pro today!
Know more. http://www.rediffmailpro.com/signup/</windows.h></conio.h></stdio.h>

Are you referring to the While loop … If so there is no
exit for the loop!

Regards,
Rajiv.

-----Original Message-----
From: asha angadi [mailto:xxxxx@rediffmail.com]
Sent: Tuesday, August 20, 2002 12:20 PM
To: NT Developers Interest List
Subject: [ntdev] doubt

hi!
i got so much information from the sites which u have given.i am
developing a software for billing.we have a card that detects
16khz cycle.nowi am able to capture DSR level.but i am unable to
stop the processing when the signal stops.also i am unable to try
it out using multihtreading.below is the code.can u please out the
error.
regards
Asha Angadi
Conevergent Technologies
Switching R&D
ITI Limited
Bangalore

#include<stdio.h>
#include<conio.h>
#include<windows.h>

#define STATUS_CHECK_TIMEOUT 20
#define INTER_SAMPLE_DELAY 5
#define MAX_SAMPLES 20
#define MIN_AUTHENTIC_VALUE (MAX_SAMPLES/2)
#define INTER_PULSE_GUARD_BAND 2800

HANDLE hComp,hEvent;
DCB dcb;
DWORD dwEvtMask,dwModemState;
bool fdsr;
float bill;
int SampleCount = 0;
int dsrCount = 0;
int Tariff_Count;
int Misses,success;
bool Changed;
void main()
{

hComp= CreateFile( “com1”,GENERIC_READ |
GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,0);
if(hComp == INVALID_HANDLE_VALUE)
{
printf(“error”);
}
if(!GetCommState(hComp,&dcb))
{
printf(“error%d”,GetLastError());
}
dcb.BaudRate = 9600;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;

success = SetCommState(hComp,&dcb);
if(!success)
{
printf(“error”);
// return false;
}

success = SetCommMask(hComp,EV_CTS | EV_DSR);
if(!success)
{
printf(“error”);
}

hEvent = CreateEvent(NULL,FALSE,FALSE,NULL);
if(WaitCommEvent(hComp,&dwEvtMask,NULL))
{
if(dwEvtMask & EV_DSR)
{
fdsr = true;
}
}
fdsr = false;
while(1)
{
if(success)
{

for(SampleCount = 0; SampleCount<(MAX_SAMPLES)/2;
SampleCount++)
{
if(!GetCommModemStatus(hComp,&dwModemState))
{
printf(“error”);
}
// fdsr = GetCommModemStatus(hComp,&dwModemState);
fdsr = MS_DSR_ON & dwModemState;
if(fdsr)
{
dsrCount++;
}
}
}

if(dsrCount>MIN_AUTHENTIC_VALUE)
{
Tariff_Count++;
Sleep(INTER_PULSE_GUARD_BAND);
Changed = true;
}
else
{
Misses++;
Changed = true;
}
bill = Tariff_Count * 1.29;
printf(“%f\n”,bill);
//printf(“\t%d”,Tariff_Count);
}
printf(“\t%d”,Tariff_Count);
}

__________________________________________________________
Give your Company an email address like
ravi @ ravi-exports.com. Sign up for Rediffmail Pro today!
Know more. http://www.rediffmailpro.com/signup/


You are currently subscribed to ntdev as: xxxxx@wipro.com
To unsubscribe send a blank email to %%email.unsub%%</windows.h></conio.h></stdio.h>