0% found this document useful (0 votes)
60 views21 pages

Appliance Control by RT-LINUX

This project controls an audio player on a Windows machine using RT-Linux. RT-Linux will send play, pause, and stop commands to the audio player over a null-modem cable. It includes code to setup the serial port communication and functions to send the commands. Periodic threads will be created to send the commands at regular intervals to play, pause or stop the audio player.

Uploaded by

Manikanta Robbi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views21 pages

Appliance Control by RT-LINUX

This project controls an audio player on a Windows machine using RT-Linux. RT-Linux will send play, pause, and stop commands to the audio player over a null-modem cable. It includes code to setup the serial port communication and functions to send the commands. Periodic threads will be created to send the commands at regular intervals to play, pause or stop the audio player.

Uploaded by

Manikanta Robbi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

APPLIANCE CONTROL BY

RT-LINUX
This project is to control Audio player by RT-Linux. An audio player program will be
running on a windows machine. We will control the audio player by RT-Linux by using
play, pause and stop commands.
To test the application we need :

◦ RT Linux installed on a Linux system.


◦ Windows to communicate with RT Linux.
◦ A null-modem cable to communicate between RT-Linux and
windows machine.
RT-Linux Serial Driver
#include <rt_com.c>
#include <rt_com.h>
#include <rt_comp.h>
rt_com functions (1): –
int rt_com_setup(unsigned int com, unsigned int baud, usigned int parity, unsigned int stopbits, unsigned int databits);
• read –
#include – int rt_com_read(unsigned int com, char *ptr, int cnt);
• write –
#include – int rt_com_write(unsigned int com, char *ptr, int cnt);
Some paths to be aware of:

•RT Linux is installed in the directory /usr/rt Linux-xxx, where xxx is the version number.
•To simplify future development, a symbolic link has been created as /usr/rt Linux 
•which points to /usr/rt Linux-xxx.
•Users are encouraged to specify their paths via this symbolic link to maintain future compatibility with
new RT Linux versions.
•/usr/rt Linux/include contains all the include files necessary for development projects.
•/usr/rt Linux/examples contains the RT Linux example programs, which illustrate the use of much of
the API.
•/usr/doc/rt Linux/man contains the manual pages for RT Linux.
•/usr/rt Linux/modules contains the core RT Linux modules.
•/usr/rt Linux/bin contains RT Linux scripts and utilities.
◦ Play.c: This file is to send the instruction to windows mac to play.
◦ Pause.c : This file is to send the instruction to pause.
◦ Stop.c : This file is to send the instruction to stop.
◦ And other files:
rtl.mk: make file contains list of obj files
1.Rtl_com.o
2.Play.o
3.Pause.o
4.Stop.o
The init_module(): which is called when the module is inserted
into the kernel. It should return 0 on
success and a negative value on failure.

The cleanup_module(): which is called just before the module is


removed.
#include <rtl.h>
The rtl.h include file contains prototypes for all the RTX
kernel routines, and some of the TCPnet and FlashFS
routines.
#include < rtl_FIFO.h >
Provide functions that initialize a FIFO, put data in, get data out, and
return the current size. The file includes a transmit FIFO using index
implementation and a receive FIFO using pointer implementation.
#include <time.h>
The time.h header defines four variable types, two macro
and various functions for manipulating date and time.
#include <pthread.h>
Pthreads are defined as a set of C language programming types
and procedure calls.
#include <asm/io.h>
This file contains the definitions for the x86 IO instructions *
inb/inw/inl/outb/outw/outl and the "string .
Declaration of variables:
int period=100msec//period is var having value of 100ms
int fifo_size=4000;
pthread_t thread;
char a[210]={};//a is array from 0 -209
void *play(void *t){
//play function with arguments
pthread_make_periodic_np(pthread_t thread, hrtime_t start time, hrtime_t period);// The thread tells
the scheduler to periodically execute this thread at a frequency of (500 microseconds).

a[0]=‘2’;//send signal 2 to play

rt_com_write() - writes cnt characters from buffer ptr to the Realtime serial
port com.
Return 0;

}
Void cleanup_module(void)
//to clean previous data
{
Pthread_delete_np(thread);
rt_com_setup(0, -1, 0, 0, 0);
}
void *stop(void *t){
//stop function with arguments
pthread_make_periodic_np(thread, gethrtime(), period);// The thread tells the scheduler to
periodically execute this thread at a frequency of (500 microseconds).

a[0]=‘3’;//send signal 2 to stop

rt_com_write(0,a,1) - writes cnt characters from buffer ptr to the Realtime


serial port com.
Return 0;

}
Void cleanup_module(void)
//to clean previous data
{
Pthread_delete_np(thread);
rt_com_setup(0, -1, 0, 0, 0);
}
void *pause(void *t){
//pause function with arguments
pthread_make_periodic_np(thread, gethrtime(), period);// The thread tells the scheduler to
periodically execute this thread at a frequency of (500 microseconds).

a[0]=‘4’;//send signal 2 to pause

rt_com_write(0,a,1) - writes cnt characters from buffer ptr to the Realtime


serial port com 0.
Return 0;

}
Void cleanup_module(void)
//to clean previous data
{
Pthread_delete_np(thread);
rt_com_setup(0, -1, 0, 0, 0);
}
THANK YOU

You might also like