RS232 - Sending Data - Only 16Bytes allowed?!
-
Hello, I am having troubles with sending data through RS232. I am using the class from Ramon de Klein: http://www.codeproject.com/system/serial.asp There I am working with the simple Serial Class (Overlapped). My problem is that I can only send 16 Byte all together. If I try to send more than 16 Byte, its sending an empty message and I get a NAK from the other side ( I monitored this with a monitoring tool). This is what the Overlapped structure is set to after sending data:
Internal 258 unsigned long InternalHigh 16 unsigned long Offset 0 unsigned long OffsetHigh 0 unsigned long Pointer 0x00000000 void * hEvent 0x00000780 void *
As you can see, InternalHigh is set to 16. I dont know why. I cant figure out why I am only allowed to send 16 Byte. The dwInQueue as well as the dwOutQueue is big enough to hold more data. The problem is that I absolutely have no clue where to search for that problem. Is there anything that restricts the number of bytes to send? Which codepart can be relevant for you? This the write method:LONG CSerial::Write (const void* pData, size_t iLen, DWORD* pdwWritten, LPOVERLAPPED lpOverlapped, DWORD dwTimeout) { // Check if time-outs are supported CheckRequirements(lpOverlapped,dwTimeout); // Overlapped operation should specify the pdwWritten variable _ASSERTE(!lpOverlapped || pdwWritten); // Reset error state m_lLastError = ERROR_SUCCESS; // Use our own variable for read count DWORD dwWritten; if (pdwWritten == 0) { pdwWritten = &dwWritten; } // Reset the number of bytes written *pdwWritten = 0; // Check if the device is open if (m_hFile == 0) { // Set the internal error code m_lLastError = ERROR_INVALID_HANDLE; // Issue an error and quit _RPTF0(_CRT_WARN,"CSerial::Write - Device is not opened\n"); return m_lLastError; } #ifndef SERIAL_NO_OVERLAPPED // Check if an overlapped structure has been specified if (!m_hevtOverlapped && (lpOverlapped || (dwTimeout != INFINITE))) { // Set the internal error code m_lLastError = ERROR_INVALID_FUNCTION; // Issue an error and quit _RPTF0(_CRT_WARN,"CSerial::Write - Overlapped I/O is disabled, specified parameters are illegal.\n"); return m_lLastError; } // Wait for the event to happen OVERLAPPED ovInternal; if (!lpOverlapped && m_hevtOverlapped) { // Setup our own overlapped structure memset(&ovInternal,0,sizeof(o
-
Hello, I am having troubles with sending data through RS232. I am using the class from Ramon de Klein: http://www.codeproject.com/system/serial.asp There I am working with the simple Serial Class (Overlapped). My problem is that I can only send 16 Byte all together. If I try to send more than 16 Byte, its sending an empty message and I get a NAK from the other side ( I monitored this with a monitoring tool). This is what the Overlapped structure is set to after sending data:
Internal 258 unsigned long InternalHigh 16 unsigned long Offset 0 unsigned long OffsetHigh 0 unsigned long Pointer 0x00000000 void * hEvent 0x00000780 void *
As you can see, InternalHigh is set to 16. I dont know why. I cant figure out why I am only allowed to send 16 Byte. The dwInQueue as well as the dwOutQueue is big enough to hold more data. The problem is that I absolutely have no clue where to search for that problem. Is there anything that restricts the number of bytes to send? Which codepart can be relevant for you? This the write method:LONG CSerial::Write (const void* pData, size_t iLen, DWORD* pdwWritten, LPOVERLAPPED lpOverlapped, DWORD dwTimeout) { // Check if time-outs are supported CheckRequirements(lpOverlapped,dwTimeout); // Overlapped operation should specify the pdwWritten variable _ASSERTE(!lpOverlapped || pdwWritten); // Reset error state m_lLastError = ERROR_SUCCESS; // Use our own variable for read count DWORD dwWritten; if (pdwWritten == 0) { pdwWritten = &dwWritten; } // Reset the number of bytes written *pdwWritten = 0; // Check if the device is open if (m_hFile == 0) { // Set the internal error code m_lLastError = ERROR_INVALID_HANDLE; // Issue an error and quit _RPTF0(_CRT_WARN,"CSerial::Write - Device is not opened\n"); return m_lLastError; } #ifndef SERIAL_NO_OVERLAPPED // Check if an overlapped structure has been specified if (!m_hevtOverlapped && (lpOverlapped || (dwTimeout != INFINITE))) { // Set the internal error code m_lLastError = ERROR_INVALID_FUNCTION; // Issue an error and quit _RPTF0(_CRT_WARN,"CSerial::Write - Overlapped I/O is disabled, specified parameters are illegal.\n"); return m_lLastError; } // Wait for the event to happen OVERLAPPED ovInternal; if (!lpOverlapped && m_hevtOverlapped) { // Setup our own overlapped structure memset(&ovInternal,0,sizeof(o
-
You can write more than 16 Bytes, I think the setup of the port. Or the endpoint of the RS232 (the HArdware) is only liking 16 Bytes. Can you write in 16 Byte loopes? If not there is big trouble.
Greetings from Germany
From germany? Nice, me too :-) No, the endpoint can handle more than 16 Bytes definetly. I managed to write a total simple communication class which can write more than 16 Bytes. And I cant find the difference between them. I dont know where to search, and what to search for. DKT
-
From germany? Nice, me too :-) No, the endpoint can handle more than 16 Bytes definetly. I managed to write a total simple communication class which can write more than 16 Bytes. And I cant find the difference between them. I dont know where to search, and what to search for. DKT
I believe you to change the Setup/Initialization of the Port. Compare every single value. There are some samples at CP try different to get it work. Have you tried to write in loops??? //Meta-Code while( DataToSend() ) { Send16Bytes(); } GetLastError() is also your friend!!!:mad: Serial Port is a legacy problem so not so many know how to handle. X|
Greetings from Germany