diff options
author | Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com> | 2017-05-19 19:58:01 +0530 |
---|---|---|
committer | Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com> | 2017-05-19 19:58:01 +0530 |
commit | 7d700e266a6d0de2f4275f09953f6cb65d7ce2d5 (patch) | |
tree | 63a9c4ce798888b8f3f3cfd54cee1a59423a15b1 /occ_pass_through.cpp | |
parent | 9bb065b8fe80b329b4321085523dafbeb64b64f9 (diff) | |
download | openpower-occ-control-7d700e266a6d0de2f4275f09953f6cb65d7ce2d5.tar.gz openpower-occ-control-7d700e266a6d0de2f4275f09953f6cb65d7ce2d5.zip |
Fix data format used in OCC communication
Amester and OCC understand only the sequence that is in bytes.
Current OCC pass-through was sending chunk of 4 bytes and that
was breaking the protocol. Since the REST server only handles 4
bytes, OCC pass-through needs to convert array of 4 bytes into
array of 2 bytes prior to sending to OCC driver.
Similarly, pass-through reader now needs to read one byte at a time
than 4 bytes.
Change-Id: Ifc24636f6b1dfb0cc0052362d2982ecfa652fec5
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
Diffstat (limited to 'occ_pass_through.cpp')
-rw-r--r-- | occ_pass_through.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/occ_pass_through.cpp b/occ_pass_through.cpp index 60dbf6c..7027d65 100644 --- a/occ_pass_through.cpp +++ b/occ_pass_through.cpp @@ -77,9 +77,17 @@ std::vector<int32_t> PassThrough::send(std::vector<int32_t> command) std::vector<int32_t> response {}; - // Amester packs data in 4 bytes - ssize_t size = command.size() * sizeof(int32_t); - auto rc = write((fd)(), command.data(), size); + // OCC only understands [bytes] so need array of bytes. Doing this + // because rest-server currently treats all int* as 32 bit integer. + std::vector<uint8_t> cmdInBytes; + cmdInBytes.resize(command.size()); + + // Populate uint8_t version of vector. + std::transform(command.begin(), command.end(), cmdInBytes.begin(), + [](decltype(cmdInBytes)::value_type x){return x;}); + + ssize_t size = cmdInBytes.size() * sizeof(decltype(cmdInBytes)::value_type); + auto rc = write((fd)(), cmdInBytes.data(), size); if (rc < 0 || (rc != size)) { // This would log and terminate since its not handled. @@ -93,7 +101,7 @@ std::vector<int32_t> PassThrough::send(std::vector<int32_t> command) // Now read the response. This would be the content of occ-sram while(1) { - int32_t data {}; + uint8_t data {}; auto len = read((fd)(), &data, sizeof(data)); if (len > 0) { |