Brad Bishop | 1164195 | 2017-08-29 11:21:15 -0400 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2017 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #include <iostream> |
| 17 | #include <string> |
| 18 | #include "../sysfs.hpp" |
| 19 | |
| 20 | int main(int argc, char* argv[]) |
| 21 | { |
| 22 | using namespace std::string_literals; |
| 23 | |
| 24 | if (argc < 6) |
| 25 | { |
| 26 | std::cerr << "Usage: " << argv[0] |
| 27 | << " [read|write] PATH TYPE N ATTR [VALUE]" << std::endl; |
| 28 | return 1; |
| 29 | } |
| 30 | |
| 31 | sysfs::hwmonio::HwmonIO io(argv[2]); |
| 32 | |
| 33 | if ("read"s == argv[1]) |
| 34 | { |
Brad Bishop | 754d38c | 2017-09-08 00:46:58 -0400 | [diff] [blame] | 35 | std::cout << io.read(argv[3], argv[4], argv[5], |
| 36 | sysfs::hwmonio::retries, sysfs::hwmonio::delay) << |
| 37 | std::endl; |
Brad Bishop | 1164195 | 2017-08-29 11:21:15 -0400 | [diff] [blame] | 38 | } |
| 39 | else |
| 40 | { |
Brad Bishop | 754d38c | 2017-09-08 00:46:58 -0400 | [diff] [blame] | 41 | io.write( |
| 42 | strtol(argv[6], nullptr, 0), |
| 43 | argv[3], argv[4], argv[5], sysfs::hwmonio::retries, |
| 44 | sysfs::hwmonio::delay); |
Brad Bishop | 1164195 | 2017-08-29 11:21:15 -0400 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 |