Structure of C Program A C program is divided into different sections. There are six main sections to a basic c program. The six sections are: Documentation Link Definition Global Declarations Main functions Sub programs The whole code follows this outline. Each code has a similar outline. Now let us learn about each of these […]
C Library
Serial Port Programming: tcflush – TCIFLUSH,TCOFLUSH example
termios The termios module provides a POSIX-style interface for controlling the behavior of TTYs and other serial communication devices on UNIX systems. All the functions operate on integer file descriptors such as those returned by the os.open() function or the fileno() method of a file object. In addition, the module relies on a large collection […]
Linux Device Driver example for dump_stack() to print the stack trace of module loading
One of the useful options in debugging is to print the call trace/stack trace. Linux kernel provides a function to print the stack trace: dump_stack(). The dump_stack function produces a stack trace much like panic and oops, but causes no problems and we return to the normal control flow. Calling dump_stack() function will print the […]
oe-pkgdata-util utility in Yocto
oe-pkgdata-util is helpful in determining why a file is included in the root file system. For example, on the development machine: $ oe-pkgdata-util find-path /etc/inittab sysvinit-inittab: /etc/inittab $ oe-pkgdata-util find-path */libncurses.so* ncurses-libncurses: /lib64/libncurses.so.5 ncurses-libncurses: /lib64/libncurses.so.5.9 ncurses-dbg: /lib64/.debug/libncurses.so.5.9 lib32-ncurses-dbg: /lib/.debug/libncurses.so.5.9 ncurses-dev: /usr/lib64/libncurses.so lib32-ncurses-dev: /usr/lib/libncurses.so lib32-ncurses-libncurses: /lib/libncurses.so.5.9 lib32-ncurses-libncurses: /lib/libncurses.so.5 The other way is given a recipe and […]
Yocto recipetool tutorial
The recipetool allows for the easier creation of a base recipe based on the source code files. As long as you can extract or point to the source files, the recipetool will generate a recipe and automatically configure all pre-built information into the new recipe file. There are two ways of writing a recipe: Writing […]
pthread_yield example in c
One advantage to using threads is that they can execute for a very long time without preventing the execution of your main thread/application. The downside is that threads that execute without an end can end up consuming too much CPU. In some cases, however, the user might need the thread to perform an action and […]
Serial Port Programming – Reading/Writing Status of Control Lines: DTR/RTS/CTS/DSR
tiocmget and tiocmset In the 2.4 and older kernels, there used to be a number of tty ioctl calls to get and set the different control line settings. These were denoted by the constants TIOCMGET, TIOCMBIS, TIOCMBIC, and TIOCMSET. TIOCMGET was used to get the line setting values of the kernel, and as of the […]
StringCchCat Function example
StringCchCat is used to concatenate one string to another string. It is also important to remember that the Strsafe functions, such as StringCchCopy() and StringCchCat(), do not have the same semantics as the strncpy_s() and strncat_s() functions. When strncat_s() detects an error, it sets the destination string to a null string while StringCchCat() fills the […]