1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

read serially

Discussion in 'MFC' started by answerme, Mar 4, 2010.

  1. answerme

    answerme New Member

    Joined:
    Dec 17, 2007
    Messages:
    114
    Likes Received:
    0
    Trophy Points:
    0
    Hi all
    I want to read number of bytes serially ,but i am getting an error that is

    Code:
    error C2664: 'CSerialCom::ReadByte' : cannot convert parameter 1 from 'DWORD [10]' to 'DWORD &'
    where buffr is
    DWORD buffr[10];
    & iam reading buffr serially below here.

    if((port.ReadByte(buffr)))


    Iam able to write perfectly but reading iam facing problem
     
  2. Gene Poole

    Gene Poole New Member

    Joined:
    Nov 10, 2009
    Messages:
    93
    Likes Received:
    5
    Trophy Points:
    0
    You'll need to post more than just that. There's no way to diagnose your error without knowing more about the problem.
     
  3. answerme

    answerme New Member

    Joined:
    Dec 17, 2007
    Messages:
    114
    Likes Received:
    0
    Trophy Points:
    0
    well actually I am sending(i.e. writing) CSTRING data through serial port. & reading it through Dword since CSerialcom readbyte has only one parameter i.e DWORD.
    Well I am able to send(write) the full data 57 char (checked in hyper terminal also).
    But when I am reading data I am getting only 46 char.. I don't know why. I tried to convert DWORD to CString but i couldnt get suceed

    Code:
    [B]Sending /Writing Data Serially[/B]
    CString data="dfdfsdfwewrrttnmnmbn12.343iuyiuyiuyiuyiyuyubnmb nbvbnbn"
    
    [B]Receiving Serially [/B]
    CSerialcom port;
    DWORD buffer;
    unsigned char frame;
    int i;
    if(port.ReadByte(buffer))>0)
    frame[i++]=(unsigned char)buffer; 
    In buffer i am receiving only 46 char
     
  4. Gene Poole

    Gene Poole New Member

    Joined:
    Nov 10, 2009
    Messages:
    93
    Likes Received:
    5
    Trophy Points:
    0
    1. What is CSerialcom? Not a standard class.

    2. "frame" is a single byte. How did you even get "frame[i++]=..." to compile?

    3. if you got this to compile, it probably ran the buffer over some critical part of your code at 46 bytes. Did it crash? Did you try to debug?
     

Share This Page