Serial Port Communications - c

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.

Related

Easy way to get a File Picker on Linux

I'm trying to write a small programme that needs to load a few files chosen by the user. I thought it'd be easier to use the Linux system's default file picker rather than write my own, but I literally don't have a clue where to even start looking.
So, can anyone recommend a quick and easy way to use the system's file picker on Linux in C?
As I commented, many Linux systems (e.g. a rented VPS, a consumer router box, ...) don't have any graphical user interfaces (often above X11).
If you want a GUI toolkit in C for Linux, consider using GTK. Then look at GtkFileChooserWidget & GtkFileChooser
If you want a GUI toolkit in C++ for Linux, consider using Qt.
If you want a terminal interface, learn ncurses.
If you want a web interface, use some HTTP server library like libonion or Wt, or make a FastCGI program for your existing web server.
Perhaps coding a simple shell script might be easier. Read Advanced Bash Scripting Guide. You could also use a scripting language like Python, Ruby, Ocaml, ...
If you don't know about Linux programming, read Advanced Linux Programming first. See also intro(2) & intro(3)
... a small program that needs to load a few files chosen by the user.
Just pass them as command-line arguments. It's much easier and doesn't tie you to a given GUI toolkit.
You can easily write a shell wrapper using kdialog on KDE, or dialog if you want curses in a terminal, or ... whatever other tool for whatever other environment.

Dynamically Configure FPGA From Host Program

I was wondering if anyone knows an efficient way to program the FPGA(PL) for a Xilinx Zynq-7 series or related devices,from a host C program (not on the SoC, but from the host PC). Is there an Xilinx API I can use/include in my program. As the only way I can think of doing it at the moment is invoking command line programming via Impact.
Basically I want to put the SDK "Program FPGA" functionality in my host C program where the user selects a prebuilt .bit file (and .elf file if possible) to program the FPGA/(SoC). This is just for a test of concept, later I would like to put this dynamic configuration onto one of the ARM CPU's.
Many Thanks
Sam
At the very least you'll need an intermediate MPU/MCU that can read from USB, as at startup most FPGAs aren't capable of much at all. I'm guessing this'll make it hard to find a MPU/library pair to do so, because there are so many options, each of which would be pretty application-specific. You're better off starting with programming them off an ARM chip, since you'll need some CPU with the FPGA in any case.
This seems somewhat useful.

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).

Good portable wiimote library with sound support?

I'm lookin for a portable wiimote library. I want to use the wiimote for the hardware it has (but I don't need to access any data stored on it).
Required features:
access to all the buttons (as an exception, no use of the power button is OK)
make the wiimote play sound
talk to nunchuks and classic controllers
preferably: make the wiimote rumble.
interface with C. Preferably native C. Bonus points for bindings with Haskell or python.
The library should port to Linux, Windows and OS X (in order of importance) and should be agnostic with respect to CPU architecture.
Anyone got a good suggestion?
Haven't use it (I've only read about the managed Wiimote library really), but you may want to check out wiiuse. It seems like the most complete of the native libararies.
Others include:
GlovePIE
WiiYourself
You can use my WiiMouse program to do this (which is based on the wiimotelib open source project), it allows you to connect via named pipes and play PCM sounds and use all the attachments including the MotionPlus, it even calculates the MotionPLus vectors for you, you can get it here:
http://home.exetel.com.au/amurgshere/wiimouse.phtml
See the download for an example on how to connect to a wiimote via named pipes and play sounds and stuff.

Resources