About serial communication and it correction

Discussion in 'General Electronics Chat' started by yousufsaleem, Feb 16, 2013.

  1. yousufsaleem

    Thread Starter New Member

    Sep 28, 2011
    16
    0
    ***At sending side***

    Code ( (Unknown Language)):
    1.  
    2. s = serial('COM1');
    3.  
    4. set(s,'BaudRate',9600,'DataBits',8);
    5.  
    6.  fopen(s);
    7. fwrite(s,'we love you')
    8.  
    9. fclose(s)
    10.  
    ***at receiving side***

    Code ( (Unknown Language)):
    1.  
    2. s = serial('COM1');
    3.  
    4. set(s,'BaudRate',9600,'DataBits',8);
    5.  
    6. fopen(s); x=fgets(s) fclose(s)
    7.  
    **but at receiving only we is coming **

    can you help me to get complete data at receiving side plz reply fast
     
    Last edited by a moderator: Feb 17, 2013
  2. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    What systems/compilers are being used?

    Also, put code inside code tags, it's the octothorpe button on the formatting bar.
     
  3. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    Also known as this: #
    (I almost had to look that word up :D)

    How do you have the whole thing connected? Two computers talking to each other? How long is the cable between them?
    You can start with making a loopback adaptor - just a female connector with pins 2 and 3 connected together, and see if you can get the text back in the same device.
     
  4. JDT

    Well-Known Member

    Feb 12, 2009
    658
    85
    What happens if you send 'weloveyou' without spaces?

    Is it that you only get the first two characters or has the space got something to do with it?

    Look up the exact operation of fgets().
     
  5. MrChips

    Moderator

    Oct 2, 2009
    12,446
    3,361
    I suspect fgets() fetches what is currently sitting in the input buffer.
     
  6. yousufsaleem

    Thread Starter New Member

    Sep 28, 2011
    16
    0
    thanks for reply ....


    i am using transducer nrf 24l01 for communication between two computers

    and i have alread checked serial communication on hyperlink or terminal

    now i m totally confused i have tried many commands but the result is same
     
  7. MrChips

    Moderator

    Oct 2, 2009
    12,446
    3,361
    You have not stated what computers and software you are using.
     
    yousufsaleem likes this.
  8. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,389
    1,605
    Single character constants are delimited with the ' symbol.

    Multiple character constants are delimited with the " symbol.

    So change:
    Code ( (Unknown Language)):
    1. fwrite(s,'we love you')
    To this:
    Code ( (Unknown Language)):
    1. fwrite(s,"we love you")
     
  9. MrChips

    Moderator

    Oct 2, 2009
    12,446
    3,361
    OP has not indicated programming language.
    It could be MATLAB.
     
  10. yousufsaleem

    Thread Starter New Member

    Sep 28, 2011
    16
    0
    ya sorry im using matlab

    and using intel dual core
     
  11. MrChips

    Moderator

    Oct 2, 2009
    12,446
    3,361
    So you are using MATLAB. How are we supposed to know that?
    What is the size of your receive buffer?
    How do you know the transmitter is completed before closing?
     
Loading...