C serial port programming

This is a discussion on C serial port programming within the C Programming forums, part of the General Programming Boards category; I have a send.c. I send: "7E 40 09 00 BE EF 05 7D 5D 06 01 02 03 04 ...

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    4

    C serial port programming

    I have a send.c.
    I send: "7E 40 09 00 BE EF 05 7D 5D 06 01 02 03 04 05 7E".
    But at the read.c, I want "Proto = 40" as the output.
    Currently in my program, the output is:
    "Proto 40 09 00 BE EF 05 7D 5D 06 01 02 03 04 05 7E".

    Here is my sample code:
    Code:
    int bufsize = 46;
            int k=0;
            int i;
            for (i=0;i<bufsize;i++)
            {
                if (buf[i]=' ')
            {
                k++;
            }
            if (k==3)
            {
                printf("Proto %s\n", buf);
            }
    Please help me...

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,849
    Interesting...

    You have the same data over here as well.
    C serial port programming - Dev Shed

    And a lot more code to show for it.

    But regrettably, it doesn't have any code tags, so it's going to get ignored.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Serial port programming
    By jitender dogra in forum C Programming
    Replies: 4
    Last Post: 07-09-2007, 04:29 AM
  2. C++ serial port programming
    By terracota in forum Windows Programming
    Replies: 4
    Last Post: 12-14-2004, 09:01 AM
  3. Need help on using C++ programming on serial port
    By PsychoMantis in forum C++ Programming
    Replies: 5
    Last Post: 07-09-2002, 07:29 AM
  4. Need help on Serial Port programming!!!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 06-04-2002, 06:02 PM
  5. programming serial com-port
    By wesentlich in forum Windows Programming
    Replies: 1
    Last Post: 09-25-2001, 02:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21