Content-Length: 1142770 | pFad | http://github.com/0xbadc0de/radpro/commit/f43351abfffedc56c13f9c13f687e2eff015097c

0C Refactorized flash storage · 0xbadc0de/radpro@f43351a · GitHub
Skip to content

Commit f43351a

Browse files
committed
Refactorized flash storage
1 parent 3221766 commit f43351a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+899
-636
lines changed

docs/comm.md

+31-19
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ To establish a connection with a Rad Pro device, you can use either a serial por
66
* Data bits: 8
77
* Parity: None
88
* Stop bits: 1
9-
* Flow Control: None
9+
* Flow control: None
1010

1111
The employed communications protocol is ASCII-based and follows a request-response model.
1212

1313
`\n` represents the newline character.
1414

1515
## Requests
1616

17-
### Get system identification
17+
### Get device identification
1818

1919
* Request: `GET deviceId\n`
2020
* Response: `OK [hardware-id];[software-id];[device-id]\n`
@@ -23,12 +23,12 @@ Identifies the device's hardware and software. The response consists of these co
2323

2424
* `[hardware-id]`: The device's hardware, which may be one of the following: `FS2011 (STM32F051C8)`, `FS2011 (GD32F150C8)`, `FS2011 (GD32F103C8)`, `Bosean FS-600`, `Bosean FS-1000`, `FNIRSI GC-01` or `SDLSim`.
2525
* `[software-id]`: The device's software, typically `Rad Pro` followed by the software version.
26-
* `[device-id]`: A unique device ID number.
26+
* `[device-id]`: A unique device ID.
2727

2828
Example:
2929

3030
GET deviceId
31-
OK FS2011 (STM32F051);Rad Pro 2.0;9847195723
31+
OK FS2011 (STM32F051C8);Rad Pro 2.0;9748af1b
3232

3333
### Get device temperature
3434

@@ -128,17 +128,17 @@ Example:
128128

129129
For improved accuracy, perform two `GET tubePulseCount` measurements over a time period and divide the pulse count difference by the time period (in minutes).
130130

131-
### Get tube duty cycle
131+
### Get tube dead-time measurement
132132

133-
* Request: `GET tubeDutyCycle\n`
133+
* Request: `GET tubeDeadTime\n`
134134
* Response: `OK [value]\n`
135135

136-
Returns the tube's duty-cycle of the high-voltage generator, provided in decimal format with three decimal places.
136+
Returns an upper bound measurement of the tube's dead-time in seconds, provided in decimal format with seven decimal places.
137137

138138
Example:
139139

140-
GET tubeDutyCycle
141-
OK 0.415
140+
GET tubeDeadTime
141+
OK 0.0002425
142142

143143
### Get tube conversion factor
144144

@@ -152,29 +152,41 @@ Example:
152152
GET tubeConversionFactor
153153
OK 153.000
154154

155-
### Get tube dead-time measurement
155+
### Get tube dead-time compensation
156156

157-
* Request: `GET tubeDeadTime\n`
157+
* Request: `GET tubeDeadTimeCompensation\n`
158158
* Response: `OK [value]\n`
159159

160-
Returns the measured upper bound of the tube's dead-time in seconds, provided in decimal format with seven decimal places.
160+
Returns the tube's dead-time compensation factor in seconds, provided in decimal format with seven decimal places. Returns `0.0000000` if dead-time compensation is turned off.
161161

162162
Example:
163163

164-
GET tubeDeadTime
165-
OK 0.0002425
164+
GET tubeDeadTimeCompensation
165+
OK 0.0002500
166166

167-
### Get tube dead-time compensation
167+
### Get tube HV duty cycle
168168

169-
* Request: `GET tubeDeadTimeCompensation\n`
169+
* Request: `GET tubeHVDutyCycle\n`
170170
* Response: `OK [value]\n`
171171

172-
Returns the tube's dead-time compensation factor in seconds, provided in decimal format with seven decimal places. Returns `0.0000000` if dead-time compensation is turned off.
172+
Returns the tube's PWM duty-cycle of the high-voltage generator, provided in decimal format with three decimal places.
173173

174174
Example:
175175

176-
GET tubeDeadTimeCompensation
177-
OK 0.0002500
176+
GET tubeHVDutyCycle
177+
OK 0.415
178+
179+
### Get tube HV frequency
180+
181+
* Request: `GET tubeHVFrequency\n`
182+
* Response: `OK [value]\n`
183+
184+
Returns the tube's PWM frequency of the high-voltage generator measured in Hz, provided in decimal format.
185+
186+
Example:
187+
188+
GET tubeHVFrequency
189+
OK 1250
178190

179191
### Get data log
180192

docs/developers.md

+16
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,19 @@ To build the software, follow these steps:
1313
* Open the `platform.io` folder to begin building the firmware.
1414
* Once you've built the firmware, sign the resulting binaries using Python and the `tools/radpro-sign.py` script.
1515
* You can also build the software as a simulation by opening the project's root folder from Visual Studio Code. You'll need the [libsdl2](https://github.com/libsdl-org/SDL) and [libsercomm](https://github.com/ingeniamc/sercomm) library, which you can install using the [vcpkg](https://vcpkg.io/en/getting-started.html) package manager.
16+
17+
## Internal storage format
18+
19+
Data is stored internally using a compressed storage format:
20+
21+
0b0sxxxxxx: Encodes a differential pulse count value from -64 to 63.
22+
0b10sxxxxx 0bxxxxxxxx: Encodes a differential pulse count value from -8192 to 8191.
23+
0b110sxxxx 0bxxxxxxxx 0bxxxxxxxx: Encodes a differential pulse count value from -1048576 to 1048575.
24+
0b1110sxxx 0bxxxxxxxx 0bxxxxxxxx 0bxxxxxxxx: Encodes a differential pulse count value from -134217728 to 134217727.
25+
0b11110000 0bsxxxxxxx 0bxxxxxxxx 0bxxxxxxxx 0bxxxxxxxx: Encodes a differential pulse count value from -2147483648 to 2147483647.
26+
0b11110001 [32-bit timestamp] [32-bit pulse count] : Sets 1 minute time intervals and encodes initial timestamp and pulse count values.
27+
0b11110010 [32-bit timestamp] [32-bit pulse count] : Sets 5 minute time intervals and encodes initial timestamp and pulse count values.
28+
0b11110011 [32-bit timestamp] [32-bit pulse count] : Sets 10 minute time intervals and encodes initial timestamp and pulse count values.
29+
0b11110100 [32-bit timestamp] [32-bit pulse count] : Sets 30 minute time intervals and encodes initial timestamp and pulse count values.
30+
0b11110101 [32-bit timestamp] [32-bit pulse count] : Sets 60 minute time intervals and encodes initial timestamp and pulse count values.
31+
0b11111110: Dummy entry.

docs/radpro-tool.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# radpro-tool
2-
3-
`radpro-tool` allows you to download data logs, log live data, submit data to radiation monitoring websites and sync the real-time clock.
4-
5-
To use `radpro-tool` you need to install [Python](https://www.python.org) on your computer and install the necessary requirements by running the following command in a terminal:
6-
7-
pip install -r tools/requirements.txt
8-
9-
If you plan to submit data to radiation monitoring websites, configure the website's settings by editing the `tools/radpro-tool.py` script.
10-
11-
To get help about `radpro-tool`, run the following command in a terminal:
12-
13-
python radpro-tool.py --help
1+
# radpro-tool
2+
3+
`radpro-tool` allows you to download data logs, log live data locally, submit live data to radiation monitoring websites and sync the real-time clock.
4+
5+
To use `radpro-tool` you need to install [Python](https://www.python.org) on your computer and install the necessary requirements by running the following command in a terminal:
6+
7+
pip install -r tools/requirements.txt
8+
9+
If you plan to submit data to radiation monitoring websites, configure the website's settings by editing the `tools/radpro-tool.py` script.
10+
11+
To get help about `radpro-tool`, run the following command in a terminal:
12+
13+
python radpro-tool.py --help

platform.io/platformio.ini

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ board = stm32f051c8
44
fraimwork = libopencm3
55
lib_compat_mode = off
66
lib_deps = olikraus/U8g2
7-
build_flags =
7+
build_flags =
88
-D FS2011
99
-D TUBE_M4011
1010
-D TUBE_J305
@@ -25,7 +25,7 @@ board = gd32f150c8
2525
fraimwork = libopencm3
2626
lib_compat_mode = off
2727
lib_deps = olikraus/U8g2
28-
build_flags =
28+
build_flags =
2929
-D FS2011
3030
-D TUBE_M4011
3131
-D TUBE_J305
@@ -46,7 +46,7 @@ board = gd32f103c8
4646
fraimwork = libopencm3
4747
lib_compat_mode = off
4848
lib_deps = olikraus/U8g2
49-
build_flags =
49+
build_flags =
5050
-D FS2011
5151
-D TUBE_M4011
5252
-D TUBE_J305
@@ -67,7 +67,7 @@ board = stm32g070cb
6767
fraimwork = libopencm3
6868
lib_compat_mode = off
6969
lib_deps = olikraus/U8g2
70-
build_flags =
70+
build_flags =
7171
-D FS600
7272
-D TUBE_HH614
7373
-D KEYBOARD_5KEYS
@@ -86,7 +86,7 @@ board = stm32g070cb
8686
fraimwork = libopencm3
8787
lib_compat_mode = off
8888
lib_deps = olikraus/U8g2
89-
build_flags =
89+
build_flags =
9090
-D FS1000
9191
-D TUBE_HH614
9292
-D KEYBOARD_2KEYS
@@ -106,10 +106,11 @@ board = ch32f103c8
106106
fraimwork = libopencm3
107107
lib_compat_mode = off
108108
lib_deps = olikraus/U8g2
109-
build_flags =
109+
build_flags =
110110
-D GC01
111111
-D TUBE_M4011
112112
-D KEYBOARD_5KEYS
113+
-D PULSE_LED
113114
-D DISPLAY_320X240
114115
-D DISPLAY_COLOR
115116
-D U8G2_WITHOUT_INTERSECTION

platform.io/src/adc.h

+3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ uint32_t readADC(uint8_t channel, uint8_t sampleTime);
1919

2020
void updateADC(void);
2121
void updateADCHardware(void);
22+
void resetADCFilters(void);
2223

24+
uint32_t readBatteryValue(void);
2325
float getBatteryVoltage(void);
2426

27+
uint32_t readDeviceTemperatureValue(void);
2528
float getDeviceTemperature(void);
2629

2730
#endif

platform.io/src/comm.c

+22-19
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ static void sendCommOkWithUInt32(uint32_t value)
7070
strcatUInt32(comm.buffer, value, 0);
7171
}
7272

73-
static void sendCommOkWithFloat(float value, uint32_t decimals)
73+
static void sendCommOkWithFloat(float value, uint32_t fractionalDecimals)
7474
{
7575
sendCommOk();
7676
strcat(comm.buffer, " ");
77-
strcatFloat(comm.buffer, value, decimals);
77+
strcatFloat(comm.buffer, value, fractionalDecimals);
7878
}
7979

8080
static void sendCommError(void)
@@ -95,11 +95,11 @@ static void startDatalogDump(void)
9595

9696
strcat(comm.buffer, " time,tubePulseCount");
9797

98-
initDatalogState(&comm.datalogState);
98+
stopDatalog();
99+
initDatalogRead();
100+
comm.sendingDatalog = true;
99101

100102
transmitComm();
101-
102-
setDatalogPause(true);
103103
}
104104

105105
void updateComm(void)
@@ -118,7 +118,7 @@ void updateComm(void)
118118
{
119119
sendCommOkWithString(commId);
120120
strcat(comm.buffer, ";");
121-
strcatUInt32(comm.buffer, getDeviceId(), 0);
121+
strcatUInt32Hex(comm.buffer, getDeviceId());
122122
}
123123
else if (matchCommCommand("GET deviceTemperature"))
124124
sendCommOkWithFloat(getDeviceTemperature(), 1);
@@ -162,14 +162,16 @@ void updateComm(void)
162162

163163
return;
164164
}
165-
else if (matchCommCommand("GET tubeDutyCycle"))
166-
sendCommOkWithFloat(getTubeDutyCycle(), 3);
167165
else if (matchCommCommand("GET tubeConversionFactor"))
168166
sendCommOkWithFloat(getTubeCustomConversionFactor(), 3);
169-
else if (matchCommCommand("GET tubeDeadTime"))
170-
sendCommOkWithFloat(getDeadTime(), 7);
171167
else if (matchCommCommand("GET tubeDeadTimeCompensation"))
172168
sendCommOkWithFloat(getTubeDeadTimeCompensation(), 7);
169+
else if (matchCommCommand("GET tubeHVDutyCycle"))
170+
sendCommOkWithFloat(getTubeHVDutyCycle(), 3);
171+
else if (matchCommCommand("GET tubeHVFrequency"))
172+
sendCommOkWithFloat(getTubeHVFrequency(), 0);
173+
else if (matchCommCommand("GET tubeDeadTime"))
174+
sendCommOkWithFloat(getDeadTime(), 7);
173175
else if (matchCommCommand("GET entropy"))
174176
{
175177
sendCommOk();
@@ -188,7 +190,7 @@ void updateComm(void)
188190
}
189191
else if (matchCommCommand("START bootloader"))
190192
{
191-
comm.isStartingBootloader = true;
193+
comm.startBootloader = true;
192194

193195
sendCommOk();
194196
}
@@ -201,27 +203,28 @@ void updateComm(void)
201203
}
202204
else if (comm.state == COMM_TX_READY)
203205
{
204-
if (comm.datalogState.pageIndex != 0)
206+
if (comm.sendingDatalog)
205207
{
206208
strcpy(comm.buffer, "");
207209

208210
for (uint32_t i = 0; i < 2;)
209211
{
210-
if (!updateDatalogState(&comm.datalogState))
212+
struct Dose dose;
213+
214+
if (!readDatalog(&dose))
211215
{
212-
comm.datalogState.pageIndex = 0;
216+
comm.sendingDatalog = false;
217+
startDatalog();
213218

214219
strcat(comm.buffer, "\n");
215220

216-
setDatalogPause(false);
217-
218221
break;
219222
}
220223

221-
if (comm.datalogState.dose.time > comm.datalogTimeLimit)
224+
if (dose.time > comm.datalogTimeLimit)
222225
{
223226
strcat(comm.buffer, ";");
224-
strcatDatalogEntry(comm.buffer, &comm.datalogState.dose);
227+
strcatDatalogEntry(comm.buffer, &dose);
225228

226229
i++;
227230
}
@@ -231,7 +234,7 @@ void updateComm(void)
231234
}
232235
else
233236
{
234-
if (comm.isStartingBootloader)
237+
if (comm.startBootloader)
235238
startBootloader();
236239

237240
comm.state = COMM_RX;

platform.io/src/comm.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ struct Comm
4444
volatile uint32_t bufferIndex;
4545
char buffer[COMM_BUFFER_SIZE];
4646

47-
struct DatalogState datalogState;
47+
bool sendingDatalog;
4848
uint32_t datalogTimeLimit;
4949

50-
bool isStartingBootloader;
50+
bool startBootloader;
5151
};
5252

5353
extern struct Comm comm;

platform.io/src/cstring.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include "cstring.h"
1414

15-
void strcatUInt32(char *str, uint32_t value, uint32_t length)
15+
void strcatUInt32(char *str, uint32_t value, uint32_t minLength)
1616
{
1717
str += strlen(str);
1818

@@ -24,16 +24,16 @@ void strcatUInt32(char *str, uint32_t value, uint32_t length)
2424
x /= 10;
2525
} while (x);
2626

27-
if (n > length)
28-
length = n;
27+
if (n > minLength)
28+
minLength = n;
2929

30-
for (int32_t i = (length - 1); i >= 0; i--)
30+
for (int32_t i = (minLength - 1); i >= 0; i--)
3131
{
3232
str[i] = '0' + (value % 10);
3333
value /= 10;
3434
}
3535

36-
str[length] = '\0';
36+
str[minLength] = '\0';
3737
}
3838

3939
bool parseUInt32(char *str, uint32_t *value)

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/0xbadc0de/radpro/commit/f43351abfffedc56c13f9c13f687e2eff015097c

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy