How do I write Arduino readings to a file on the computer? - c

I want to write Arduino's data readings to a file locally on the computer. I MUST do this in C for a specific reason. Also, I am working in Windows 7 not Linux.
I couldn't find any useful codes on the internet that satisfies my requirement. Can anyone help?

You should think about Processing it uses the same IDE as the Arduino. It has common libraries for sending data back and forth between the Arduino and host PC. Where Processing is built on Java, its code that you write looks just like that of the Arduino's C++

Related

Can you open and edit .c files in the Arduino IDE? And subsequently load them to an Arduino board

I have been trying to open c files in the Arduino IDE (which some people claim is possible).
I have not been able to do so.
How can I program the Arduino in c given that I have a project/files in another IDE? (for example, MPLABX)
I am not sure what you are trying to archive. Is it that you want to open it via the Arduino IDE or also compile the source code?
I am not aware of programming in bare c in the Arduino IDE. But if you're looking into using real c code, it might be a good time start either compiling and uploading via terminal yourself, or use an IDE which is suited for development with micro controllers.
I think you can tell the Arduino IDE to more elaborately log outputs. This would tell you exactly the commands the IDE is using (uses avrdude). Then you can use an IDE/Editor of your choice for coding.
Otherwise, have a look at eg. Atmel Studio. They also support Arduino.
There are two answers in one:
If you really want to use the ArduinoIDE you have to have a basic *.ino file having at least the defines and includes which are in the project file and the reqiured setup() loop() usually whats in main in c goes to loop() in ArduinoIDE. Thats the stoney path because there are some specific issues coming from the philosophy behind ArduinoIDE (help makers with little (no?) programming skills to get started quickly).
If you just need the Arduino tool-chain and want to work more comfortable you have two other options:
EclipseIDE with the Sloeber add-on. Download the Sloeber-AllInOne-Package for an easy start and THEN add the other modules you need (like for web development or similar)
PlatformIO an IDE for micro controller development - there is also a cloud based version for testing around.
All mentioned tools are real open source and available cross PC platform and not a gift from a company like MS for probably later lockin of devs

How to Program in C for Hengstler C51 Thermal receipt Printer

I am working on project where I need to print a receipt through a Hengstler C51 Thermal Printer. The device is working fine and it's printing images too.
I need to write a C program which can open my printer and print my preformatted receipt which is going to contain a simple logo.
I can not figure out how to proceed.
The API Documentations given by Hengstler really stinks. I installed all their drivers and API libs though. I am using Ubuntu 11.04.
I am looking for some sample or demo programs to start from.
might just be easier to make program that creates your image file instead of programming the printer. I can't find anything on this thing. Your best bet is to trial and error on that API and Docs they provide, if you don't like my idea.

Interacting with terminal in Linux using C/C++

Is it possible to have an interactive session with terminal using a C code.
I need to open a PORT using terminal and then start GtkTerm and then send hexadecimal code to it . So, can I do this all using a C code.
Please suggest me other alternatives to communicate through serial Port . But I need to make a GUI , so that I dont need to go to terminal again and again because it is not expected from every user.
Thanks :)
Many years ago, I used Greenleaf's CommLib for serial communications and found it to be an extremely high quality product. It looks like they've added some terminal emulation capabilities to it as well, so there is some ability to add interactivity to the your code. They have C and C++ versions of the library.
It is a bit pricey, but I suppose you have to pay for high quality. http://www.greenleafsoft.com/
This is a Windows library though, so maybe it won't work for you. I found a free eBook for serial communications on POSIX systems here:
http://www.easysw.com/~mike/serial/serial.html
Now you need to add in terminal emulation for the interactive part. libvterm looks like it tries to provide emulation: http://sourceforge.net/projects/libvterm/
It looks like there is a terminal emulation widget for QT too, which might work better: http://qt-apps.org/content/show.php/QTermWidget?content=82832
Good luck...not many people deal with serial communications anymore.

Serial programming in C , in DOS

I need to do some basic serial programming in C, in old 16-bits MS-DOS. I know the basics, i had coded some serial comm. in some microcontroller some decades ago, but that's now ancient knowledge, and it's not so easy to find information.
I'm looking for some reliable (not necessarily free or open source) library or code, and general information.
I'm also looking for some instructions/advise about how to test it, assuming I'm developing on a Win7 machine. For example, if it would be possible to emulate a null-modem connection from a console terminal in my Win7 machine to a emulated COM port running my DOS program in a DOSBOX environment, or something like that.
What a coincidence. Just finished a college class on low level hardware using it.
These will guide you (rolling your own, no libs, not hard!):
Course slides on serial port
BeyondLogic tutorial on it
Course lab script on the practical project using the serial port
The last one's in Portuguese, but the code samples/tables are commented and with variable names in english.
Good luck.
About emulating. Virtual PC, for example, allows piping of data through a virtual serial port using a text file. Google it. You can also use Windows 98 with DJGPP for compiling this. Use old command.com (which is a self contained dos emulator, basically). You can also restart in MS-DOS.
Download virtual box, and install DOS (available with MSDN subscriptions, as are free alternatives as FreeDOS).

Serial Port Communications

I am trying to create a GUI for a c code written in LINUX.
This code basically connects two systems, opens the serial port, writes data from one system to the other via the port.how do I go about this?
The development tools present with me are Qt designer version 3.3.5 and K Develop, which one should I use.and how to go about it?
In Linux, every hardware device is mapped to the file-system using standard file-system permissions.
If you're just using a simple serial port protocol under Linux, you can treat any serial port device as a file. Meaning, they can be opened, read, written and handled just using standard files.
The 'filename' for a serial port is typically /dev/ttyS0 or /dev/ttyUSB0 depending on the type of serial port. It is often symlinked to /dev/modem on regular distributions.
I think you may be looking in the wrong place. You should probably search the web for a tutorial on C++ programming, or get a book on it (there are plenty out there). Once you're comfortable with C++ (it'll take a while if you're not already), you can start to read about writing KDE applications. There are probably some introductory things to read on the KDE website, and don't forget that Google is your friend throughout the process ;-)
By the way, Qt Designer is just a program for doing GUI layouts, while KDevelop is a full featured IDE that combines Qt Designer, a text editor, and a bunch of other stuff. You can use KDevelop for writing anything from very simple "Hello World" C++ programs up to, well, something as complex as KDevelop itself.
If you've actually got to write the serial port part (I'm not clear on this from your question), the other system calls you'll need to know about are 'ioctl' and 'termios', to set various serial port parameters.
Seems your using QT. You should try QextSerialPort which is a serial port class for QT.
The doc.trolltech.com site has a huge amount of documentation. You should go definitely take a look.
I would use the latest available Qt library for your distro, since it is a new developpment.
Regarding the serial port C code, I would keep it and call it from your C++ code. Beware of time consuming operations that can ruin the interactive feeling of your app.

Resources