Fixed small bug in MMPP_control (infinity waiting when one of MCUs not working)

This commit is contained in:
eddyem 2019-08-26 14:43:33 +03:00
parent 0556b0bbce
commit 12bd669ff6
3 changed files with 110 additions and 38 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.8.0, 2019-03-11T13:48:47. --> <!-- Written by QtCreator 4.8.0, 2019-04-19T09:10:33. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@ -13,42 +13,108 @@ Simple CLI control tool allowing bash scripting
- `-b, --baudrate=arg`-- TTY baudrate (raw number, e.g. 115200), default speed is 9600; - `-b, --baudrate=arg`-- TTY baudrate (raw number, e.g. 115200), default speed is 9600;
- `-d, --comdev=arg`-- terminal device filename, default path is `/dev/ttyUSB0`; - `-d, --comdev=arg`-- terminal device filename, default path is `/dev/ttyUSB0`;
- `-h, --help`-- show this help; - `-h, --help`-- show this help;
- `-l, --lin2=arg`-- move waveplate linear stage to N steps - `-l, --lin2=arg`-- move wave-plate linear stage to N steps;
- `-p, --pidfile=arg`-- PID-file name - `-p, --pidfile=arg`-- PID-file name (default is `/tmp/MMPP_control.pid`);
- `-q, --quiet`-- don't show anything @screen from stdout - `-q, --quiet`-- "almost quiet" mode for external calls (show minimum on stdout, output will be like `param=value`);
- `-r, --rot2=arg`-- rotate lambda/4 to given angle - `-r, --rot2=arg`-- rotate lambda/4 to given angle;
- `-s, --status`-- get device status - `-s, --status`-- get device status;
- `-t, --temp`-- show temperature of both MCU - `-t, --temp`-- show approximate temperature of both MCU;
- `-w, --wait`-- wait while all previous moving ends - `-w, --wait`-- wait while all previous moving ends, this is useful if you ran this tool several times with `-y` and want to wait until all moving ends;
- `-y, --async`-- asynchronous moving - don't wait - `-y, --async`-- asynchronous moving, the tool won't wait and will exit after all commands being sent.
## Output in normal mode
When "quiet" mode inactive, the output is human-readable and have a lot of information. E.g. "status" request in case of success will show something like
Pol: M0ST M0LEFT M0POS - M1ST M1LEFT M1POS || L/4: M0ST M0LEFT M0POS - M1ST M1LEFT M1POS
Pol: STOP 0 0 - STOP 0 29700 || L/4: STOP 0 0 - STOP 0 0
ESW00 ESW01 ESW10 ESW11 || ESW00 ESW01 ESW10 ESW11
HALL RLSD RLSD RLSD || HALL RLSD HALL RLSD
The first and third rows are headers. To the left of `||` delimiter is polaroid data, to the right -- wave-plate data.
The second row shows values of linear stage (`M0ST`) and rotator (`M1ST`) motors state, steps left (`MxLEFT`) and current positions (`MxPOS`). The last row shows Hall sensors state for all end-switches (`HALL` -- end-switch is active, `RLSD` end-switch is inactive and for linear stage there could be third value: `BTN` meaning that user button pressed).
When sending raw data you will get some additional information, e.g.:
./MMPP_control -a 1GC
Send raw string: 1GC
Receive: CONFSZ=36
DEVID=1
V12NUM=605
V12DEN=94
I12NUM=3
I12DEN=4
V33NUM=1
V33DEN=1
ESWTHR=500
MOT0SPD=3
MOT1SPD=5
MAXSTEPS0=50000
MAXSTEPS1=50000
USARTSPD=9600
INTPULLUP=1
REVERSE0=1
REVERSE1=0
USTEPS=16
ACCDECSTEPS=50
DATAEND
(this is a request for settings stored in device flash memory).
When moving, the output would be like first two strings of `-s` with dynamically changed values of steps left and current position of moving parts.
The output of temperature request would be like:
./MMPP_control -t
MCU1 temperature: 39.6 degC
MCU2 temperature: 35.1 degC
## Keywords in *quiet* mode ## Keywords in *quiet* mode
This mode is useful for batch files and running from external soft. Its main difference is no unuseful information and data format like `parameter=value`. For example, temperature request have output like:
- - temperature of x'th MCU; POLTEMP=35
- POLTEMP=35
L4TEMP=32.9 L4TEMP=32.9
- POLMOTOR0=SLEEP
POLPOS0=0 Where `POLTEMP` is temperature of polarisator controller, L4TEMP -- temperature of wave-plate controller.
When moving, there's no output, only waiting for moving ends. It's better to run this tool with `-y` flag and asynchronously start it later with `-s` flag to receive current state.
The output of `MMPP_control -qs` will be like:
POLMOTOR0=MOVE
POLSTEPSLEFT0=742
POLPOS0=4558
POLESW00=RLSD POLESW00=RLSD
POLESW01=RLSD POLESW01=RLSD
POLMOTOR1=SLEEP POLMOTOR1=MOVE
POLPOS1=0 POLSTEPSLEFT1=7289
POLPOS1=32411
POLESW10=RLSD POLESW10=RLSD
POLESW11=RLSD POLESW11=RLSD
POLSTEPSLEFT0 L4MOTOR0=MOVE
POLSTEPSLEFT1 L4STEPSLEFT0=642
L4MOTOR0=SLEEP L4POS0=4358
L4POS0=-40001
L4ESW00=RLSD L4ESW00=RLSD
L4ESW01=RLSD L4ESW01=RLSD
L4MOTOR1=SLEEP L4MOTOR1=MOVE
L4POS1=-40001 L4STEPSLEFT1=1542
L4POS1=6458
L4ESW10=RLSD L4ESW10=RLSD
L4ESW11=RLSD L4ESW11=RLSD
L4STEPSLEFT0
L4STEPSLEFT1
Where
- `xxxMOTOR0` and `xxxMOTOR1` are linear stage and rotator motors of polaroid (`POL`) or wave-plate (`L4`) controller;
- `xxxSTEPSLEFTy` are amount of steps left (these values are displayed only when corresponding motor is moving);
- `xxxPOSy` are current positions (in steps!!!);
- `xxxESWyz` are end-switches values (`y==0` -- linear stage, `y==1` -- rotator; `z==0` -- zero's end-switch, `z==1` -- limiting end-switch).
**Warning**! Be careful: positions of rotators have different values. When you call this tool to move any rotator to given angle, you should point this angle in degrees. When you get state of device, you will see this angle in steps! These parameters defined in `tty_procs.h`:
#define STEPSREV1 (36000)
#define STEPSREV2 (28800)
This mean that polaroid rotator have 36000 steps per revolution (100 steps per degree), wave-plate rotator have 28800 steps per revolution (80 steps per degree).

View File

@ -222,7 +222,10 @@ int tty_wait(){
printf("%39s", "failed "); printf("%39s", "failed ");
}else printf("%s", bufo); }else printf("%s", bufo);
} }
}else if(!quiet) printf("%39s", "failed"); }else{
if(!quiet) printf("Pol: %39s", "failed ");
chk1 = 0;
}
if(alive[2]){ if(alive[2]){
chk2 = parsestatus("2GS"); chk2 = parsestatus("2GS");
if(!quiet){ if(!quiet){
@ -230,11 +233,14 @@ int tty_wait(){
if(chk2 == -1){ if(chk2 == -1){
chk2 = 1; chk2 = 1;
++failcount; ++failcount;
printf("%39s", "failed"); printf("%38s", "failed");
}else printf("%s", bufo); }else printf("%s", bufo);
printf(" \r"); printf(" \r");
} }
}else if(!quiet) printf("%39s", "failed"); }else{
if(!quiet) printf(" || L/4: %38s\r", "failed");
chk2 = 0;
}
} }
if(!quiet) printf("\n\n"); if(!quiet) printf("\n\n");
if(failcount > 4){ if(failcount > 4){
@ -297,7 +303,7 @@ static void ttystat(){
if(alive[2]) chk2 = parsestatus("2GS"); if(alive[2]) chk2 = parsestatus("2GS");
printf(" || L/4: "); printf(" || L/4: ");
if(chk2 == -1){ if(chk2 == -1){
printf("%39s", "failed"); printf("%38s", "failed");
}else printf("%s", bufo); }else printf("%s", bufo);
printf("\n"); printf("\n");
sprintf(&buff[24], "|| "); sprintf(&buff[24], "|| ");