Pages: [1]   Go Down
Author Topic: Need help about a communication function  (Read 1349 times)
0 Members and 1 Guest are viewing this topic.
Curitiba PR, Brazil
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, Im beginner about Arduino, I have a Boarduino, that's Duemilianove compatible, and do I need a function that creates a file in windows, with data previously stored in memory of ATMEGA. I don't have any idea of how to do this function...
The file created, could be a simple txt file. I believe this is not dificult to do, but Im on search for this for a week.

And also need, send this file to printer, and print it. =/

Someone can help me?

Thanks
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 618
Posts: 33945
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to run something like hyper terminal to take what is coming from the serial port of the arduino and dump it as a text file on the PC.

Otherwise you can write a program in some language like processing to do this.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 388
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You might be able to use Gobetwino, which, according to that link, can "Log data from Arduino to a file [on a Windows PC], with an optional timestamp."

Note, Gobetwino is not open source software (yet).

Hope this helps.
« Last Edit: September 23, 2009, 10:49:26 pm by TBAr » Logged

Curitiba PR, Brazil
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Really, I search this program (Gobetwino) and seems to be very interesting...

But anyone know, if I want that the Arduino send the order to print this file, I will need a protocol communication with the printer, or maybe needs to create a .bat file... or yet Gobetwino can make this?

thanks for help
Logged

Spokane, Washington
Offline Offline
God Member
*****
Karma: 1
Posts: 686
My name is Bob, and I'm an addict.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, I've been watching some tutorials on C++, just to get a better handle of Functions, pointers, addressing.. still a bit confusing, but there are some good videos out there, take a look at this one, it's for Writing to a .txt file, keep in mind, this is in Visual Basic C++.

You'll need to implement reading from a Serial Connection, and print the data coming from the Serial connection, to the .txt file, which seems fairly easy. I haven't worked with C++ much, so I wasn't sure how to implement a library, which is required for the Serial communication (I believe?).


This guy has alot of decent C++ tutorials, everything you'll need to work with in the Arduino environment. smiley-grin
Best of luck, and do let us know how you get on!
Logged

Curitiba PR, Brazil
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Very good! This like to seems easy, Is that like this that I need. I have been research about and I think that is needs make a program in the computer write in VB, C++, Delphi, etc., and put only a protocol in Arduino controller (Firmata).

My problem is that I need:
- Reading the information printed, like in "serial monitor".
- Generate an log with this information.
- send instruction to the printer to print it.

If the best solution is create a program in the computer, this will out of thought, because my program are a little extensive...
Logged

Curitiba PR, Brazil
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I made some some testes with the Gobetwino and works fine but, when I send ctrl+p to print the log, the taskmanager open the "window of print" anda the Gobetwino can't control this window =/

Knows someone how to make an executable file in Windows, that on run it, only print a desired file?
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 388
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
or maybe needs to create a .bat file...
If you are using the term .bat instead of .cmd, that is a good sign. (That is a compliment from one old-timer to another.)

If you still use LPT1 to connect your printer, you can have Gobetwino run
   copy [file.txt] LPT1:
but I don't know how to print to a USB printer from the DOS command line.

The DOS print command also uses LPT1, I think, but you can take a look at that too.

Sorry I don't have a better answer for you right now.
Logged

Curitiba PR, Brazil
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

TBAr, so need I to do a DOS program in C language, with this command that you mentioned? Need some library to make this? Or the Gobetwino accepts this code?

Otherwise... have another way to open a file (don't needs to create a log, only open) with the Arduino microcontroller? Because I need to See the information in serial monitor, and this isn't possible in same time while run the Gobetwino.

Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 388
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, with the changed requirement to see the data in the serial monitor instead of creating a file on Windows, it's time for you to learn how to communicate with a program on the PC, I think. You talked about Firmata before, that seems like a good solution. So study the information at http://arduino.cc/en/Reference/Firmata and see what that can do for you.
Logged

Curitiba PR, Brazil
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm almost find the solution, I make a program in Processing, that read and send data for serial port, and creates the file that I need... I'm only don't know a function to send a file to the printer =/
If someone tell me a function in C or java for example, I can make a program, and call this executable in processing...
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 388
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could always use the following pseudo-code:

   open the file for reading
    read each line and print it, using printf()
    close the file


You shouldn't need anything more than that, should you?
« Last Edit: September 30, 2009, 07:43:31 am by TBAr » Logged

Curitiba PR, Brazil
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No my friend, I need to send the file to the Printer, and print it in the Printer, not in the monitor...
Logged

Curitiba PR, Brazil
Offline Offline
Sr. Member
****
Karma: 0
Posts: 259
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I found!

I only wrote in notepad

Code:
@echo off

cls
type "C:\...\filename.txt" > "LPT1"

without quotes,
and save as .bat

after, I call this saved file in my program write in processing at moment that I need.

Is simpler than I thought...

Thanks for help!
Logged

Pages: [1]   Go Up
Jump to: