Commit 2b294aea authored by dargaud@lpsc.in2p3.fr's avatar dargaud@lpsc.in2p3.fr
Browse files

First commit of already working code

parent 1cbe466c
TB_Phytron
TB_Phytron_QuickTest
core*
phytron = TB_Phytron
REMOTE?=0 # This is when running test progs from remote system via ssh tunnels. Also use "make REMOTE=1"
COPT = -ggdb -O0 -Wall -std=gnu11 -fdiagnostics-color=always -DUSE_COLOR_MSG -DREMOTE=${REMOTE}
CC=gcc
TP=-DSTANDALONE_TEST_PROG
$(phytron): $(phytron).c $(phytron)_QuickTest.c
@# $(CC) $(COPT) -c $< # Compile as obj to test lib capabilities (optional)
$(CC) $(COPT) $< -o $@ $(TP) # Compile as standalone test program
$(CC) $(COPT) -Wno-unused-function $^ -o $@_QuickTest
clean:
rm -f $(phytron) *_QuickTest *_Calib core*
This diff is collapsed.
#ifndef __TB_PHYTRON_H
#define __TB_PHYTRON_H
// Low level commands
extern int PH_Init(void);
extern int PH_CloseAll(void);
extern int PH_SendCommand(char* Reply, const char* Command, ... )
__attribute__ (( __format__( __printf__, 2, 3 ) ));
// Higher level
extern int PH_Reset(void);
extern char* PH_GetStatusBinaryMsg(char *Reply);
extern char* PH_GetSystemStatusMsg(int);
extern char* PH_GetSystemStatusExtendedMsg(int);
extern int PH_GetStatusAxes(void);
extern int PH_GetInitiatorsStatus(void);
extern int PH_Reset(void);
extern int PH_MoveToLimit(int Dir);
extern int PH_DoAct(void);
extern int PH_GetAxisCount(void);
extern int PH_GetSystemStatusAxes(void);
extern int PH_AxisStatusRequest(int val);
extern int PH_ResetAxis(void);
extern int PH_DoAxisStop(void);
extern int PH_EnAxisPowerStage(int val);
extern int PH_RelPosition(double val);
extern int PH_AbsPosition(double val);
extern int PH_FreeRunning(int val);
extern int PH_SetParamValue(int param,int val);
extern int PH_GetParamValue(int param);
extern int PH_SetParamValueF(int Param, double val);
extern double PH_GetParamValueF(int Param);
extern double PH_DbgGetPosition(double *P);
extern double PH_GetPosition(void);
// Higher level still
extern int PH_DoGetGeneralStatus(void);
// For use by common control program
extern int TB_Phytron_Init(void);
extern int TB_Phytron_Close(void);
extern int TB_Phytron_MoveAbs(double Angle);
extern char* TB_Phytron_Status(void);
extern char* TB_Phytron_LastErrMsg(void);
#endif
#include <stdlib.h>
#include <stdio.h>
#include <iso646.h>
#include <string.h>
#include <unistd.h> // sleep()
#include "TB_Phytron.h"
#include "UseColors.h"
#define SYNTAX printf(BLD WHT "%s [pos1] [pos2] [...]\n"\
"\tposN\t\tMove Phytron motor to position pos (in deg), then pause\n"\
NRM, argv[0]);
int main(int argc, const char* argv[]) {
int Ret, i;
if (argc==1 or
argc>1 and 0==strcmp(argv[1], "-h")) { SYNTAX; return 1; }
if (( Ret=TB_Phytron_Init() )) return Ret;
for (i=1; i<argc; i++) {
printf("Moving to argv[%d]: %.2f\n", i, atof(argv[i]));
if (( Ret=TB_Phytron_MoveAbs(atof(argv[i])) )) break;
else printf("Press Enter: "), getchar();
}
if (Ret) printf(BLD RED "Sequence aborted at step %d: %s\n" NRM, i, TB_Phytron_LastErrMsg());
printf(BLD WHT "%s\n" NRM, TB_Phytron_Status());
TB_Phytron_Close();
return Ret;
}
#ifndef __USE_COLORS_H
#define __USE_COLORS_H
// #define USE_COLOR_MSG
// or use -DUSE_COLOR_MSG in the Makefile
// If defined, all you need to output text in color on the console
// is to start your printf with one of those color macros and end it with NRM (for NoRMal)
// printf(RED "some red text and %d\n" NRM, I);
// 2 command line tests:
// for i in {1..9}; do echo -e "\e[$i""m different style\e[0m"; done
// for i in {30..37} {90..97}; do echo -e "\e[$i""m colorful text\e[0m"; done
#ifdef USE_COLOR_MSG
#define NRM "\e[0m" // Normal
// Foreground colors
#define DFC "\e[39m" // Default foreground color
#define BLK "\e[30m" // Black
#define DRD "\e[31m" // Red
#define GGR "\e[32m" // Green
#define DYE "\e[33m" // Yellow
#define DBL "\e[34m" // Blue
#define DPR "\e[35m" // Purple
#define DCY "\e[36m" // Cyan
#define GRE "\e[37m" // Light grey
#define DRK "\e[90m" // Dark grey
#define RED "\e[91m" // Light red
#define GRN "\e[92m" // Light green
#define YEL "\e[93m" // Light yellow
#define BLU "\e[94m" // Light blue
#define PRP "\e[95m" // Light magenta
#define CYA "\e[96m" // Light Cyan
#define WHT "\e[97m" // White
// Styles:
#define BLD "\e[1m" // Bold
#define DIM "\e[2m" // Dim
#define ITL "\e[3m" // Italic
#define UND "\e[4m" // Underline
#define BLN "\e[5m" // Blink
#define REV "\e[7m" // Reverse
// #define HID "\e[8m" // Hidden
#define STK "\e[9m" // Strike
// Background colors
#define BDBC "\e[49m" // Default background color
#define BBLK "\e[40m" // Black
#define BDRD "\e[41m" // Red
#define BGGR "\e[42m" // Green
#define BDYE "\e[43m" // Yellow
#define BDBL "\e[44m" // Blue
#define BDPR "\e[45m" // Purple
#define BDCY "\e[46m" // Cyan
#define BGRE "\e[47m" // Light grey
#define BDRK "\e[100m" // Dark grey
#define BRED "\e[101m" // Light red
#define BGRN "\e[102m" // Light green
#define BYEL "\e[103m" // Light yellow
#define BBLU "\e[104m" // Light blue
#define BPRP "\e[105m" // Light magenta
#define BCYA "\e[106m" // Light Cyan
#define BWHT "\e[107m" // White
#else
#define NRM
#define DFC
#define BLK
#define DRD
#define GGR
#define DYE
#define DBL
#define DPR
#define DCY
#define GRE
#define DRK
#define RED
#define GRN
#define YEL
#define BLU
#define PRP
#define CYA
#define WHT
#define BLD
#define DIM
#define ITL
#define UND
#define BLN
#define REV
// #define HID
#define STK
#define BDBC
#define BBLK
#define BDRD
#define BGGR
#define BDYE
#define BDBL
#define BDPR
#define BDCY
#define BGRE
#define BDRK
#define BRED
#define BGRN
#define BYEL
#define BBLU
#define BPRP
#define BCYA
#define BWHT
#endif
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment