etcetera99
asked on
Problem with WriteFile() and the serial port
I am writing a program for Windows 95 which takes joystick input and sends data about the joystick across the serial port. My data gets there all in one piece, but my program causes the computer to crash practically constanty. I have isolated the problem down to the WriteFile call in which a 32 to 64 byte string is sent. I have tried sending the data using the OVERLAPPED stuff and without it. I can't get it to work. Please help.
thanks,
mitch
thanks,
mitch
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry This code is sample block write for principal and interest.
used functions are making by me, and include nothing another.
used functions are making by me, and include nothing another.
/*
FUNCTION: AddToLinkedList(PWRITEREQU EST)
PURPOSE: Adds a node to the write request linked list
PARAMETERS:
pNode - pointer to write request packet to add to linked list
*/
void AddToLinkedList(PWRITEREQU EST pNode)
{
PWRITEREQUEST pOldLast;
//
// add node to linked list
//
EnterCriticalSection(&gcsW riterHeap) ;
pOldLast = gpWriterTail->pPrev;
pNode->pNext = gpWriterTail;
pNode->pPrev = pOldLast;
pOldLast->pNext = pNode;
gpWriterTail->pPrev = pNode;
//
#define WRITE_BLOCK 0x06
LeaveCriticalSection(&gcsW riterHeap) ;typedef struct STATUS_MESSAGE;
struct STATUS_MESSAGE * glpStatusMessageHead;
struct STATUS_MESSAGE * glpStatusMessageTail;
typedef struct STATUS_MESSAGE
{
struct STATUS_MESSAGE * lpNext; // pointer to next node
char chMessageStart; // variable length string start here
} STATUS_MESSAGE;
//
// notify writer thread that a node has been added
//
if (!SetEvent(ghWriterEvent))
ErrorReporter("SetEvent( writer packet )");
return;
}
you must insert member function/variable in youer classs.
removed error handler functions and etc functions, or make function
do allocation value.
This code used linked list for memoy block Write
and write com port by byte. "WriterGeneric" is memory pointer increased by byte and write in com port.
FUNCTION: AddToLinkedList(PWRITEREQU
PURPOSE: Adds a node to the write request linked list
PARAMETERS:
pNode - pointer to write request packet to add to linked list
*/
void AddToLinkedList(PWRITEREQU
{
PWRITEREQUEST pOldLast;
//
// add node to linked list
//
EnterCriticalSection(&gcsW
pOldLast = gpWriterTail->pPrev;
pNode->pNext = gpWriterTail;
pNode->pPrev = pOldLast;
pOldLast->pNext = pNode;
gpWriterTail->pPrev = pNode;
//
#define WRITE_BLOCK 0x06
LeaveCriticalSection(&gcsW
struct STATUS_MESSAGE * glpStatusMessageHead;
struct STATUS_MESSAGE * glpStatusMessageTail;
typedef struct STATUS_MESSAGE
{
struct STATUS_MESSAGE * lpNext; // pointer to next node
char chMessageStart; // variable length string start here
} STATUS_MESSAGE;
//
// notify writer thread that a node has been added
//
if (!SetEvent(ghWriterEvent))
ErrorReporter("SetEvent( writer packet )");
return;
}
you must insert member function/variable in youer classs.
removed error handler functions and etc functions, or make function
do allocation value.
This code used linked list for memoy block Write
and write com port by byte. "WriterGeneric" is memory pointer increased by byte and write in com port.
ASKER