Thread: Serial Communication Help

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    56

    Serial Communication Help

    Hi everyone,
    Basically I need help on serial communications. Its my first time using it. Well here's the thing: My PC is connected to a microcontroller and I am trying to send code to the microcontroller. The code I am trying to send is on file so I have to use fopen to open it. The file has a bunch of Hex code thats needs to be sent. I am using the HANDLE command for serial communication. My question is this: Can I send a code a byte at a time using the WriteFile and a loop?

  2. #2
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    It sounds like you're not on a *nix platform, so you should tell us your OS and compiler.

    I can tell you with a pretty good deal of certainty that the last thing you want to do is send one byte at a time. That'll eat up CPU like it's going out of style.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    56
    I am using Visual C software and Windows XP. Is it possible to send everything at once?

  4. #4
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    Quote Originally Posted by NewGuy100
    Is it possible to send everything at once?
    The answer to that likely is system-dependent.

    It's best to send as much as you can at once. The fewer system calls you make to write this file, the better.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  5. #5
    Registered User
    Join Date
    Jul 2005
    Posts
    56
    Thanks really appreciate it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Duplex communication thro serial port
    By Priyachu in forum Linux Programming
    Replies: 1
    Last Post: 05-30-2009, 04:03 AM
  2. Serial port Communication
    By vin_pll in forum C++ Programming
    Replies: 23
    Last Post: 01-07-2009, 09:32 AM
  3. Serial pot communication through c program
    By vin_pll in forum C++ Programming
    Replies: 2
    Last Post: 01-01-2009, 12:52 PM
  4. Please help with serial communication problem - Long
    By spdylude in forum Windows Programming
    Replies: 3
    Last Post: 04-06-2005, 09:41 AM
  5. Serial communication packets
    By Roaring_Tiger in forum C Programming
    Replies: 3
    Last Post: 04-26-2003, 08:33 AM