diff options
| author | Manuel Traut <manut@mecka.net> | 2013-01-15 01:41:38 +0100 |
|---|---|---|
| committer | Manuel Traut <manut@mecka.net> | 2013-01-15 01:41:38 +0100 |
| commit | 33a7f9331cbce18c5f706ed614cbd7c04ef7a9da (patch) | |
| tree | 563f7fe6cd4db2860b22f0c7d8120ff5a919c4eb /io/bin/generic_gpio/generic_gpio.cpp | |
| parent | 7dd28a3fa96564bb4135a1c4dc936e5824c4c2e7 (diff) | |
improve gpio.conf config format
make it easier for humans to read and bette parseable
Signed-off-by: Manuel Traut <manut@mecka.net>
Diffstat (limited to 'io/bin/generic_gpio/generic_gpio.cpp')
| -rw-r--r-- | io/bin/generic_gpio/generic_gpio.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/io/bin/generic_gpio/generic_gpio.cpp b/io/bin/generic_gpio/generic_gpio.cpp index 06b9f59..f0e2145 100644 --- a/io/bin/generic_gpio/generic_gpio.cpp +++ b/io/bin/generic_gpio/generic_gpio.cpp @@ -18,13 +18,13 @@ static void err (const char *s) class GPIO : public Distrio_Digital_i { public: - GPIO (std::string io_name, int value, ::Distrio::Direction dir) : - Distrio_Digital_i (io_name, dir) { + GPIO (int _id, std::string name, ::Distrio::Direction dir) : + Distrio_Digital_i (name, dir) { int ret = -1; if (dir == ::Distrio::OUTPUT) - ret = gpio_open_dir (&p, value, GPIO_OUT); + ret = gpio_open_dir (&p, _id, GPIO_OUT); if (dir == ::Distrio::INPUT) - ret = gpio_open_dir (&p, value, GPIO_IN); + ret = gpio_open_dir (&p, _id, GPIO_IN); if (ret) { id(-1); err ("open gpio failed\n"); @@ -93,16 +93,22 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) for (i = 0; i < num; i++) { ::Distrio::Direction dir; + char tmp [255]; char *name = _iniparser_getsecname (d, i); - char *direction = _iniparser_getstring (d, "direction", "unknown"); - int value = _iniparser_getint (d, "value", -1); + int id; + char *direction; + sprintf (tmp, "%s:id", name); + id = _iniparser_getint (d, tmp, -1); + sprintf (tmp, "%s:direction", name); + direction = _iniparser_getstring (d, tmp, "unknown"); if (strcmp (direction, "in") == 0) dir = ::Distrio::INPUT; else dir = ::Distrio::OUTPUT; - GPIO *g = new GPIO (std::string (name), value, dir); + std::cout << " new gpio: " << id << ": " << name << std::endl; + GPIO *g = new GPIO (id, std::string (name), dir); if (g->id () == -1) { err ("create gpio object failed - hw error?\n"); |
