Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. RS232 - Sending Data - Only 16Bytes allowed?!

RS232 - Sending Data - Only 16Bytes allowed?!

Scheduled Pinned Locked Moved C / C++ / MFC
helpcomquestionworkspace
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kreatief
    wrote on last edited by
    #1

    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

    K 1 Reply Last reply
    0
    • K Kreatief

      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

      K Offline
      K Offline
      KarstenK
      wrote on last edited by
      #2

      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

      K 1 Reply Last reply
      0
      • K KarstenK

        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

        K Offline
        K Offline
        Kreatief
        wrote on last edited by
        #3

        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

        K 1 Reply Last reply
        0
        • K Kreatief

          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

          K Offline
          K Offline
          KarstenK
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups