Interacting with terminal in Linux using C/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.

Related

C or C++ programming with contikiOS on Arduino Due

What I need to do is to compile and run a program written in C/C++ on Arduino.
I'm ok with every open source RTOS if it supports C especially struct.
So I have found contikiOS does that, and tried to get started.
But I guess contikiOS doesn't support Arduino port anymore and Due is quite recent model so that I couldn't find proper information.
If you know any information on it or want me to help, please give me an advice.
Ah, do you have any other recommendation for RTOS?
Thanks.
If what you need is to run a simple c/c++ software, you have to know that the arduino environment support c/c++ code, as explained in the arduino homepage http://code.google.com/p/arduino/
If for your requirements, you need to use a real time operating system, there is a contikiOS version for Arduino (Contiki-Arduino).
Last but not least, if you are a beginner, i would advice you to use a popular RTOS, to find support on internet easily if you need it. Sadly, i am not an expert on that field. But when i google it, i find Duinos, maybe you could have a look on it.

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

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++

Creating a touch screen driver for OS X: where to start?

OK, so I recently purchased an Acer T232HL touch screen display to hook up to my Macbook Pro as a secondary monitor. To give you an idea, here's my setup.
OS X doesn't support this monitor in any way, so as you can see in the screenshot I'm actually running Windows 8 through VMware, which proxies the USB connection to Windows perfectly where the touch events are supported. But obviously this isn't ideal.
There's at least one 3rd party driver for OS X that looked sort of promising, but it doesn't seem to support multitouch from this device, it's expensive, and generally was a pain to get working to the small degree it was. There's also mt4j but best I could tell after running their examples, it doesn't support this device at all.
So here's my question: what exactly am I in for if I wanted to write a driver for this thing? I'm mostly a web developer with years of experience with Ruby, Objective-C (and a little C), Javascript, etc. I have never ventured into any kind of hardware programming, so from the surface this feels like an interesting while intimidating challenge.
I know at some level I need to read data from USB. I know this will probably mean trying to reverse engineer whatever protocol they're using for the touch events (is it possible this will be entirely custom?). However I haven't got a clue where to start - would this be a kernel extension? In C, I presume? Would love a high level overview of the moving parts involved here.
Ultimately I want to use the touch screen to drive a specialized web interface (running in Chrome), so ideally I could proxy the touch events straight to Chrome without the OS actually moving the mouse cursor to the touch location (so have the UI behave just as it would on an iPad), but regardless of whether this is technically possible, I'd love to start with just getting something working.
You're going to want to start with Apple's I/O Kit documentation. You can hope that the touchscreen isn't completely custom, though there must be some part that's not standard USB HID, or it would work already. If there are any linux (or other open source) drivers available, you'll have the advantage that somebody already did some of the reverse engineering for you. As an alternative to the I/O Kit, you might also want to look into libusb, which might make your brain hurt less when getting started. If you end up needing to write a kext, that might not help you anymore, though.
As to some of your specific questions:
would this be a kernel extension?
Maybe, maybe not. I'm not really up on the Mac OS X driver situation, but I did write some totally user-space USB code for OS X many years ago. Maybe you'll be as lucky.
In C, I presume?
Probably. I/O Kit itself is written in a subset of C++, so you can probably use that too, if you prefer.
is it possible this will be entirely custom?
Unfortunately, yes, it's possible.
Good luck!

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