Here is my communication program (sorry for some french definitions and
comments).
It compiles with gcc -I/usr/lib/xmgr/include trace.c -L/usr/lib/xmgr/lib
-lacegr_np
It assumes that the data are written by the rt-task in the rt-fifo with the
format given by the struct "samp" which contains the channel (voie in
french) and the value (valeur). Then you can display any channel you need.
You should not refresh too often the display of xmgr: the display becomes
blinking.
I hope it will help you.
Sam.
/* Inspired from rt-linux example (see copyright notice below) and xmgr
library example */
/* modified by Samuel Guibal (2000-2001), cnrs,
([EMAIL PROTECTED]) */
/* User space program that reads data from a rt-linux fifo and sends the
data */
/* to the plot program xmgr for displaying */
/*
* RTL scheduling accuracy measuring example, user program
*
* (C) Michael Barabanov, 1997
* (C) FSMLabs 1999. [EMAIL PROTECTED]
* Released under the GNU GENERAL PUBLIC LICENSE Version 2, June 1991
* Any use of this code must include this notice.
*/
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <acegr_np.h>
#include <fcntl.h>
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
#ifndef EXIT_FAILURE
# define EXIT_FAILURE -1
#endif
struct samp
{
int voie;
int valeur;
};
int main()
{
int fd0;
int n;
int i, tension;
struct samp lecture;
/* ouverture du RT-FIFO de lecture des donn�es */
/* open rt-fifo for reading data */
if ((fd0 = open("/dev/rtf6", O_RDONLY)) < 0) {
fprintf(stderr, "Error opening /dev/rtf6\n");
exit(1);
}
/* Start xmgr with a buffer size of 2048 and open the pipe */
if (ACEgrOpen(2048) == -1) {
fprintf (stderr, "Can't run xmgr. \n");
exit (EXIT_FAILURE);
}
/* Send some initialization commands to xmgr */
ACEgrPrintf ("world xmin 0");
ACEgrPrintf ("world ymin 0");
ACEgrPrintf ("world xmax 100");
ACEgrPrintf ("world ymax 10000");
ACEgrPrintf ("xaxis tick major 20");
ACEgrPrintf ("xaxis tick minor 10");
ACEgrPrintf ("yaxis tick major 2000");
ACEgrPrintf ("yaxis tick minor 1000");
ACEgrPrintf ("sets symbol 3");
ACEgrPrintf ("sets symbol fill 1");
ACEgrPrintf ("sets symbol size 0");
/* lecture des donn�es dans le RT-FIFO*/
/* reading data from rt-fifo */
i=0;
while (1)
{
/* read rt-fifo... */
n = read(fd0, &lecture, sizeof(lecture));
tension = 10000 - (lecture.valeur * 10000) / 2047;
/* display channel, value and converted value to the console*/
printf("%i\t%i\t%i\t%i\n",i, lecture.voie, lecture.valeur,
tension);
fflush(stdout);
/* transmit data to xmgr */
ACEgrPrintf ("g0.s0 point %d, %d", i, tension);
ACEgrPrintf ("world xmin %d",i-80);
ACEgrPrintf ("world xmax %d",i+20);
ACEgrPrintf ("autoscale yaxes");
ACEgrPrintf ("redraw");
i++;
}
/* Tell xmgr to save the data when closing*/
ACEgrPrintf ("saveall \"sample.gr\"");
/* Flush the output buffer and close the pipe */
ACEgrClose ();
return 0;
}
At 10:10 16/01/02 , vous avez �crit:
> Is it posible, that you send me this program, that sets communication
> with xmgr.
>
>Rok
>--
>
>On Tue, 15 Jan 2002 12:00:11
> Samuel Guibal wrote:
> >I am using the scientific plot program xmgr. I have written a simple c
> >program that reads data from a rt-fifo and sends them to xmgr using a
> >routines from an interface library provided with xmgr.
> >The graphical interface is not really beautyful but is convenient and the
> >communication is very easy to setup.
> >Sam.
> >
> >At 14:45 14/01/02 , vous avez �crit:
> >>Hello
> >>I am new to real-time programing so i decided to use Rtic-lab for a start.
> >>I am developing PID controller for a motor and it is starting to work. But
> >>i have problem because i would like to plot data on scren and only program
> >>i found is rtic-scope, but i can only plot one signal at a time.
> >>So i have some questions:
> >>Does anyone use rtic-scope?
> >>How can i plot more than one signal?
> >>Is there any similar program so that i can plot data from rtic-lab?
> >>
> >>Thanks
> >>
> >>Rok Ostrovrsnik
> >>Student
> >>
> >>
> >>-- [rtl] ---
> >>To unsubscribe:
> >>echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> >>echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> >>--
> >>For more information on Real-Time Linux see:
> >>http://www.rtlinux.org/
> >
> >--
> >Dr Samuel Guibal
> >Laboratoire Aim� Cotton, CNRS
> >b�t. 505, Campus d'Orsay, 91405 Orsay cedex
> >tel. (+33) 1 69 35 20 51, fax (+33) 1 69 35 21 00
> >[EMAIL PROTECTED]
> >http://www.lac.u-psud.fr/
> >http://www.lac.u-psud.fr/coldmolecules
> >
> >
> >-- [rtl] ---
> >To unsubscribe:
> >echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> >echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> >--
> >For more information on Real-Time Linux see:
> >http://www.rtlinux.org/
> >
> >
>
>
>-- [rtl] ---
>To unsubscribe:
>echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
>echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
>--
>For more information on Real-Time Linux see:
>http://www.rtlinux.org/
--
Dr Samuel Guibal
Laboratoire Aim� Cotton, CNRS
b�t. 505, Campus d'Orsay, 91405 Orsay cedex
tel. (+33) 1 69 35 20 51, fax (+33) 1 69 35 21 00
[EMAIL PROTECTED]
http://www.lac.u-psud.fr/
http://www.lac.u-psud.fr/coldmolecules
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/