Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Arduino Serial Data -> Visual Basic -> Text File -> Read in w/ C++

Status
Not open for further replies.

ECE12

Newbie level 4
Joined
Oct 7, 2011
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,344
I'm interfacing the Arduino uC with Visual Basic. I can read in the serial data from the uC w/ Visual Basic just fine, and then I write these values into a text file. I try to read in the text file values using a C++ program, but it doesn't read in the values correctly. In C++ I'm trying to read in the values as INT's but I think when I'm writing the values to a file in VB, it is converting it to something other than ints. I don't think its type is a string either, because when I try to read in a string it has a couple of junk characters prior to the actual string of text.


It's strange, because while looking at the text file using Notepad that I generated in VB, it appears to look just how I want it to. Do you have any experience with this sort of thing?


The arduino uC is outputting DEC values which the VB program reads. I store the input values into a label, and then I write the label text to a file. So is the values in the created .txt non integer values? I'm pretty sure this is the problem, but I don't know a good way of generating the text file correctly when I need to be able to append a space between each integer value, so I can differentiate between them when I start to read them into my C++ program.

---------- Post added at 02:15 ---------- Previous post was at 00:26 ----------

Okay. Let me explain myself better.

In VB 2010 I write to a text file 'A'. I open the file in notepad, and sure enough the 'A' is there. As you would expect. Now, when I try to read the file in C++ it reads in the A as some weird symbol character. Can anyone explain that to me?
 

So is the values in the created .txt non integer values? I'm pretty sure this is the problem, but I don't know a good way of generating the text file correctly when I need to be able to append a space between each integer value, so I can differentiate between them when I start to read them into my C++ program.

You are right, the problem is in the way you are writing to the file. It sounds from what you said that you are writing strings not integers. Moreover, the strange characters you saw may be the "CR" and "LF" characters.

What function are you using in VB to write to the file? Is it "Put" or "Print"?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top