-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetTACurrent.c
More file actions
55 lines (41 loc) · 1.11 KB
/
setTACurrent.c
File metadata and controls
55 lines (41 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
Set TA Current
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "interfacing/topticaLaser.h"
#include "interfacing/kenBoard.h"
#include "fileTools.h"
int main (int argc, char* argv[]){
int i;
float current, presentValue;
int line=0;
int laserSocket;
char systemCfgFileName[]="/home/pi/RbControl/system.cfg";
char buffer[1024];
FILE *systemCfgFile;
initializeBoard();
laserSocket=initializeLaser();
if (argc==2){
current=atof(argv[1]);
}else {
return 1;
}
presentValue = getAmpCurrent(laserSocket);
printf("Present Value: %4.2f\n", presentValue);
setAmpCurrent(laserSocket,current);
line=getLineNumberForComment(systemCfgFileName,"#PumpLaserAMPCurrent(mA)");
systemCfgFile=fopen(systemCfgFileName,"r+");
if(!systemCfgFile){
printf("Unable to open systemCfgFile\n");
exit(1);
}
for(i=0;i<line;i++){
fgets(buffer,1024,systemCfgFile);
}
fprintf(systemCfgFile,"#PumpLaserAMPCurrent(mA):\t%4.2f\n",current);
fclose(systemCfgFile);
close(laserSocket);
return 0;
}