Skip to content

Commit 35ff018

Browse files
committed
Add generator program for configuration accessor headers.
1 parent 9b1502e commit 35ff018

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

config-fields

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
baudrate,int,baud rate,Baud rate in bits per second
2+
bits,int,data bits,Number of data bits
3+
parity,enum sp_parity,parity setting,Parity setting
4+
stopbits,int,stop bits,Number of stop bits
5+
rts,enum sp_rts,RTS pin behaviour,RTS pin mode
6+
cts,enum sp_cts,CTS pin behaviour,CTS pin mode
7+
dtr,enum sp_dtr,DTR pin behaviour,DTR pin mode
8+
dsr,enum sp_dsr,DSR pin behaviour,DSR pin mode
9+
xon_xoff,enum sp_xonxoff,XON/XOFF configuration,XON/XOFF mode

config-header.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pattern = str.join('', open("config-pattern").readlines())
2+
for line in open("config-fields").readlines():
3+
print pattern.format(*line.rstrip("\n").split(","))

config-pattern

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Set the {2} for the specified serial port.
3+
*
4+
* @param port Pointer to port structure.
5+
* @param {0} {3}.
6+
*
7+
* @return SP_OK upon success, a negative error code otherwise.
8+
*/
9+
enum sp_return sp_set_{0}(struct sp_port *port, {1} {0});
10+
11+
/**
12+
* Get the {2} from a port configuration.
13+
*
14+
* The user should allocate a variable of type {1} and pass a pointer to this
15+
* to receive the result.
16+
*
17+
* @param config Pointer to configuration structure.
18+
* @param {0}_ptr Pointer to variable to store result.
19+
*
20+
* @return SP_OK upon success, a negative error code otherwise.
21+
*/
22+
enum sp_return sp_get_config_{0}(const struct sp_port_config *config, {1} *{0}_ptr);
23+
24+
/**
25+
* Set the {2} in a port configuration.
26+
*
27+
* @param config Pointer to configuration structure.
28+
* @param {0} {3}, or -1 to retain current setting.
29+
*
30+
* @return SP_OK upon success, a negative error code otherwise.
31+
*/
32+
enum sp_return sp_set_config_{0}(struct sp_port_config *config, {1} {0});

0 commit comments

Comments
 (0)