CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Posts
    79

    Sending uncoded zero (ASCI) data on RS232

    I want to send uncoded (ASCII) numbers over the RS232 interface. I'm having problem with sending the number 0. Since this termitaes the string that I'm trying to send.

    int zero = 0;
    char h = 'h';
    char e = 'e';

    Meddelande.Format("%c%c%c", h, zero, e);
    MeddelandeStorlek = Meddelande.GetLength();

    length = tmpStr.GetLength();
    CheckWrite = WriteFile(Port, (LPCSTR)Meddelande,
    MeddelandeStorlek, Bitskickade, NULL);

    Since zero will terminate the string e is never sent.
    How do I get around the termination function of NUL?

  2. #2
    Join Date
    Sep 2002
    Location
    DC Metro Area, USA
    Posts
    1,509
    Is there any reason why you can't send a memory block? So for the simple case:
    Code:
     
    
    char buf[16]; // just for example; could be allocated
    
    buf[0] = 'h';
    buf[1] = 0;
    buf[2] = 'e';
    
    length = tmpStr.GetLength();
    CheckWrite = WriteFile(Port, (LPCSTR)buf,
    3, Bitskickade, NULL);
    bytz
    --This signature left intentionally blank--

  3. #3
    Join Date
    Jul 2003
    Posts
    79
    OK,
    I try to do it this way.
    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured