Reading in ReadFile function can't be done through COM port

Hello,
   I try to transfer file(in .txt format) from my test PC 
to my working PC through serial port(COM port). 
   One pc I open hyper terminal and set a connection in 
9600(baud)-8(data bit)-none(parity)-1(stop bit)-none(flow 
control).In another PC I write the code below in vc++ 
6.0. 
   I select Transfer->Send Text File and open a text file 
in my test PC. Then I run this code in my working PC. 
Altough ReadFile function doesn't get error message. 
dwBytesRead shows 0 during reading and text in text file 
does not transfer to MyBuffer.
   My code is :

///////////////////////////////////////////////////
      DWORD m_dwError;
      HANDLE hPort = CreateFile("COM2", GENERIC_READ, 0, 
0, OPEN_EXISTING, 0, 0);
      if(hPort == INVALID_HANDLE_VALUE) {
	m_dwError = GetLastError();
	AfxMessageBox("CreateFile error occured");
      }
      DCB m_DCB;
      if(GetCommState(hPort, &m_DCB) == FALSE){
	m_dwError = GetLastError();
	AfxMessageBox("GetCommState error occured");
      }
      m_DCB.BaudRate = CBR_9600;
      m_DCB.ByteSize = 8;
      m_DCB.StopBits = ONESTOPBIT;
      m_DCB.Parity = NOPARITY;
      m_DCB.fRtsControl = RTS_CONTROL_DISABLE;
      m_DCB.fDtrControl = DTR_CONTROL_DISABLE;
      m_DCB.fOutxCtsFlow = FALSE;    
      m_DCB.fBinary = TRUE;
      m_DCB.fDsrSensitivity = FALSE;
      m_DCB.fInX = FALSE;
      m_DCB.fOutX = FALSE;
      m_DCB.fNull = FALSE;
      m_DCB.fAbortOnError = TRUE;
      m_DCB.fOutxDsrFlow = FALSE;
      m_DCB.fParity = 0;
      if(SetCommState(hPort, &m_DCB) == FALSE){	
	m_dwError = GetLastError();
	AfxMessageBox("SetCommState error occured");
      }
      COMMTIMEOUTS cto;
      cto.ReadIntervalTimeout = 5;   
      cto.ReadTotalTimeoutConstant = 300; 
      cto.ReadTotalTimeoutMultiplier = 1;
      if(SetCommTimeouts(hPort, &cto) == FALSE) {
	m_dwError = GetLastError();
	AfxMessageBox("SetCommTimeouts error occured");
      }
      
      DWORD dwBytesRead = 0;	
      char myBuffer[60];
	
      SetFilePointer(hPort, 0, NULL, FILE_BEGIN);
      for(int i =0; i < 10; i++) 
      {
	if(ReadFile(hPort, &myBuffer, 1, &dwBytesRead, 
                    NULL) == FALSE) 
	    AfxMessageBox("Error occured while reading to 
                           the serial port!!!"); 
      }
////////////////////////////////////   

how can I see the text in myBuffer? What is my error?

best regards  
0
pera323 (3)
12/12/2003 1:13:35 PM
vc.mfc 33608 articles. 0 followers. Follow

0 Replies
392 Views

Similar Articles

[PageSpeed] 44

Reply:

Similar Artilces:

need some help please, read inside, cheers!!
Hello Peeps! I am trying to work out a formula that can count multiple strings i.e. =COUNTIF($E$3:$E$40,"Setup") But not only have it count look for the word setup, have it look for another word to i.e!!! =COUNTIF($E$3:$E$40,"Setup", "Done") This doesn't work but u get the jist of what i need, any help would be much appreciated!!me! Thanks Alot Kami Wilson Use separate countifs: =COUNTIF($E$3:$E$40,"Setup") + COUNTIF($E$3:$E$40,"Done") Andy. "Wilson" <Lordwils@btopenworld.com> wrote in message news:78na00ppvvbsqt...

Time functions #2
Hi, I have to do some time calculations and I have a formula that outputs in minutes and I have to subtract a standard time to this number of minutes. For example, I have 8:00 AM in one cell and 20.68 minutes on an other cell. The output that I am expecting is 7:39 AM. Does anybody know how to bring an output like that by subtracting the minutes? Please help. Thanks With 8:00 AM in A1 and 20.68 in B1, use this formula =A1-B1/(24*60) Why does it work? Because Excel stores time as a fraction of a day. We convert minutes to days by dividing by 24*60 (24 hr/day and 60 min/hr) You could just u...

I cannot read forwarded messages. I only get an email address
For some reason, when someone forwards a message to me all that shows up is the email address of the person who originally sent the message. Any ideas? Change your View>Encoding setting. "Michelle10000" wrote: > For some reason, when someone forwards a message to me all that shows up is > the email address of the person who originally sent the message. Any ideas? ...

Reading raw messages
I'm having a spam problem (yes, I know, who isn't!!!) and I would like to read the raw message, as it comes in from the POP server. I want to examine the message headers, etc. I can either do this in Outlook 2003 or in Exchange 2003, as I own and run both. When I was running MDaemon, I could access the mailbox store and read the raw messages. Ms, in their wisdom, in Exchange 2003, make this very difficult and hide this "raw" information away. I reckon Exchange Server is the place to look - if you export messages from Outlook 2003, even in text mode, you only get the sanitis...

Adding functionality to MS Outlook Express
Hi, I am looking for help to integrate anti-spam open source programs with MS Outlook Express :- - SpamPal - http://www.spampal.org/ - Spamato - http://www.spamato.net/ The problem is to provide a library that will facilitate this. I have read the MSDN Messaging and Collaboration documentation which gives the ability to get notifications of new messages and to access message folders :- http://msdn2.microsoft.com/en-gb/library/ms709546.aspx The next need is to add a toolbar (with buttons for SPAM/NOSPAM) and to detect what messages are selected in the message window. The MSOE...

Inserted rows, now need Counta function
Hi I've got a data dump. I've figured out how to insert a blank row after a change in name in column A and insert "Total" - so... bill.... bill.... bill Total - bob.... bob.... bob.... bob Total - What I need in column C next to total is to insert the COUNTA function for each person. Any ideas? cheers You say your code inserts a blank row after a change in name and inserts "Total", but your example doesn't show this. Can you post the code you are using to do your "insert"? It will probably be easier to handle the ...

Send email without read access for queues
I got the problem that a user should be able to send emails with the webclient but he should not be able to see the defined queues. Thats not possible. In my opinion it does not make sense at all that you need read privileges on queues to send emails out of the web client. That should be changed. My suggestions are: 1. Let users send emails when they have the privilege to create activities. or 2. Define a new privilege for sending emails AND (I find that one pretty important) 3. Show only those items in the queue that a user has at least read privileges for. In my case the user doe...

If Function Possibilities
Is there a way to set up in a cell A1, something like... If the formula used in cell B1 is "here I would type the actual formula in," then display the words "works," else display "mistake" ? -- rheller ------------------------------------------------------------------------ rheller's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=24081 View this thread: http://www.excelforum.com/showthread.php?threadid=377045 That's a pretty cryptic post. Do you mean: In A1: =IF(B1=n,"Works","Mistake") where 'n...

Writing Access functions
I am an old FoxPro programmer (but have been out of programming for many years) and I have been through the Access basics that I have been able to find on line. So I can create tables, forms enter data the basics. I am learning VBA no problem there. Now I want to write some functions. I would like to write one function that is passed an ID and returns the last name of the person having that ID. I would like to write this function in two ways: 1. Connect to a table in my DB find the ID and return the name 2. Have the function perform a query that returns a record set from which t...

reading file name from folder function
I am using Access 97. Just wonder if there is a fuction which can read all the file name from a folder and put it to a column in a table. Please let me know. Thanks. Hi. >I am using Access 97. Just wonder if there is a fuction which can read all >the file name from a folder and put it to a column in a table. Please see the getFileInfo( ) function in the tip, "How to compare the contents of two directories," on the following Web page for an example: http://www.access.qbuilt.com/html/vba1.html HTH. Gunny See http://www.QBuilt.com for all your database needs. See http...

Function Keys in Excel
Can someone please tell me what the F2 key does in Excel 2000? I have a column of data which has been copied from Access 2000 into an Excel 2000 sheet. It is numeric data and when I use the "Countif" function on this data, it doesn't calculate. However, if I press the "F2" function key in any of the cells, something happens to the data so that the "countif" function recoginises it. Can anyone explain what is happening here? Thank you. -- LPS F2 allows you to edit directly in the cell, do you have calculations set to automatic under tools>calcul...

faq: type of CArray as function parameter create errors
Hi, class CMyPoint { public: long x; long y; CArray<int,int&> m_intSegmentNo; CMyPoint(); virtual ~CMyPoint(); CMyPoint(const long &xx, const long &yy); CMyPoint(const CMyPoint &cmpt); CMyPoint(const CPoint &cpt); CMyPoint& operator = (const CMyPoint &assmypt); CMyPoint& operator = (const CPoint &asspt); bool operator == (const CMyPoint &rmypt);//const CMyPoint &lmypt, bool operator != (const CMyPoint &rmypt);//const CMyPoint &lmypt, }; .... class CSegment { public: CList<CMyPoint,CMyPoint&> m_PointList; CSeg...

Function for convertion of leters doesn't work.
I'm using function LOWER to convert string i my table on small size but Access gives me a message that the function is not defined.Please, do you know another function? MS Access does not have a LOWER function. Try LCase() instead. -- Cheryl Fischer Law/Sys Associates Houston, TX "Stenli" <svet2000@seznam.cz> wrote in message news:10b201c3626e$b613a050$a301280a@phx.gbl... > I'm using function LOWER to convert string i my table on > small size but Access gives me a message that the function > is not defined.Please, do you know another function? ...

Report Writer Functions #2
Where can I find instructions and examples on the various report writer functions? I've installed the SDK but I don't see anything there. The Report Writer On-line manual (Help - Printable Manuals - Reporting - Report Writer) has a fairly good description of the functions in Chapter 6. Do you look there or is there a specific function that you did not find there for which you are searching? "Elaine" wrote: > Where can I find instructions and examples on the various report writer > functions? I've installed the SDK but I don't see anything there. Hi El...

Public Function not running
Hey, I have a public function that I call from a cell. The function is: Public Function QuitTime(strQuitTime As String) As Date Dim strHour, strMin As String Dim intHour, intMin As Integer Dim dtTime As Date strHour = Left(strQuitTime, 2) strMin = Right(strQuitTime, 2) dtTime = strHour & ":" & strMin dtTime = dtTime + Range("MainSheet!B2") ' this cell contains the value today() QuitTime = dtTime End Function Anyway, I run a vlookup on this array from another sheet and when ever i run that vlookup, it makes all the cells in th...

Question on "Value" function
In trying to use Excel to help solve a mathematical puzzle, I would like to calculate the result of applying the mathematical operator in one cell to the numbers in two other cells. Example: A1 contains 2, B1 contains +, C1 contains 3. In D1, create a formula that will give the result of 2 + 3, i.e. 5. I have tried (among many other attempts) =VALUE(CONCATENATE(A1, B1, C1)), but it gives me a #VALUE! error. What am I missing? Hi this is not possible without using VBA. try the following UDF: Public Function my_calculate(op1 As Range, operand As Range, op2 As Range) my_calculate = Ap...

Reading Layout problem, and labels problem.
I am running XP Home Edition. I have Office 2003, Student and Teacher Edition, which has developed two Word problems. - The Reading Layout mode shows only one page instead of two. - When I define labels, there is no border around the labels on the screen. I only recently began creating labels, so I don't know when this came about. I have disabled System Restore, so that isn't an option. I reinstalled Office, but that didn't fix either of the Word problems. I used the Save My Settings Wizard for the reinstallation, and I wonder that that mi...

Reading Outlook 2003 pst file in Outlook 2007
My computer recently died and has been replaced with a new one running Win 7 / Outlook 2007. Is there a way I can read my old Outlook 2003 emails without importing them into my current email folders? I don't want to clutter up my current inbox with old emails, but I still need access to them. I would like to import my contacts, however. Sure. Use file, open, outlook data file. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com/ Outlook Tips by email: mailto:dailytips-subscribe-r...

reading outlook file (email messages)
I would like to read outlook files from my previous computer that was saved onto a cd. How can I access or read these e-mail messages. Is it possible to retrieve attachement as well? Hearing you soon. SF You will need to copy the file to your hard drive, remove the read-only tick mark from the property page and use File->Open in Outlook to open the file. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the SWEN virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.com and find...

Missing engineering functions
In an earlier version of Excel, I had "engineering functions" like =dec2hex and =hex2dec. Not, in Excel 2003, I see them in the "help files' but not in my list of available formulas. How do I get them to work in Excel 2003? Thanks in advance, Geoff Waters Glendale, CA Geoff, I don't have Excel 2003, but you should be able to go to Tools | Add-ins and check mark "Analysis Took Pak" in the list that appears. Regards, Jim Cone San Francisco, CA "Geoff" <grw888@hotmail.com> wrote in message news:zwfIc.299$Qu5.238@newsread2.news.pas.earthli...

Read Receipt Function in outlook
The read receipt option is no longer working in Outlook Small Business Edition for XP 2002. I have not made any recent changes to my outlook setup. Does anyone know how I can trouble shoot this? ...

Indirect and Address Functions to Determine Schedule #3
I am struggling with writing an Excel formula that I would greatl appreciate some help on. In theory this sounds quite simple. I have a table which shows th progression it takes, in months, to move from one 'level' to the next. Another larger table shows how a number of 'starting' individuals woul progress through their levels based on the progression table mentione earlier. e.g. [FONT=courier new]Progression Table[/FONT] ----------------------- Months Level One 1 Level Two 2 Level Three 3 etc. Duration Table # of People Jan Feb M...

Multiple "SUM IF" functions in one formula??
I know it can be done, Excel can do anything but I'm not sure if I can even explain it. For example, I want column D2 to display a qty IF a customer number equals a specific value AND a part number equals a specific value. Basically Column A is a list of part numbers, and Row 1 is a list of customers. I need to pull how many parts each customer has ordered. Hi see: http://www.xldynamic.com/source/xld.SUMPRODUCT.html -- Regards Frank Kabel Frankfurt, Germany "Dax" <dax.tipton@smc.com> schrieb im Newsbeitrag news:593e3ca7.0408301337.7b8f6a35@posting.google.com... > I ...

Forest Plots......can these be done in excel or powerpoint
Forest Plots......can these be done in excel or powerpoint Only if you have the trees! To be serious, please tell what is a forest plot then we might be able to help best wishes -- Bernard V Liengme www.stfx.ca/people/bliengme remove caps from email "Claire8" <Claire8@discussions.microsoft.com> wrote in message news:F067271C-7101-400D-B319-D490695F8103@microsoft.com... > Forest Plots......can these be done in excel or powerpoint it has a horizontal axis and the vertival axis in in the middle of that. There is a value which is plotted as a rectangle and then a range...

Outlook today function
When I click on the customize outlook today button nothing happens. What should I do. OL2000: You Cannot Customize Outlook Today After You Install Critical Update 813489 for Internet Explorer: http://support.microsoft.com/default.aspx?scid=kb;EN-US;820575 You can edit the registry to make changes to Outlook Today. http://www.outlook-tips.net/howto/oltoday.htm -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Coauthor, OneNote 2003 for Windows (Visual QuickStart Guide) Author, Google and Other Search Engines (Visual QuickStart Guide) Outlook Tips: http://ww...