diff --git a/sbe_chipOp_handler.cpp b/sbe_chipOp_handler.cpp
index f662690..05d506f 100644
--- a/sbe_chipOp_handler.cpp
+++ b/sbe_chipOp_handler.cpp
@@ -1,49 +1,120 @@
-#include <stdexcept>
 #include <array>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <poll.h>
+#include <endian.h>
 #include <sbe_chipOp_handler.hpp>
+#include <file.hpp>
 namespace openpower
 {
 namespace sbe
 {
 namespace internal
 {
-/*! \union sbeRespHeader_t
- *  Defines the breakup of the SBE FIFO chip operation response header.
- */
-union sbeRespHeader_t
-{
-    uint32_t commandWord; /**<Entire 32 bit command word */
-    struct
-    {
-        uint8_t command: 8; /**<command value for which response is obtained */
-        uint8_t commandClass: 8; /**< Class of the command */
-        uint16_t magic: 16; /**< Magic code obtained in the response */
-    };
-} __attribute__((packed));
-
 
 constexpr uint16_t MAGIC_CODE = 0xC0DE;
 constexpr auto SBE_OPERATION_SUCCESSFUL = 0;
 constexpr auto LENGTH_OF_DISTANCE_HEADER_IN_WORDS = 0x1;
 constexpr auto LENGTH_OF_RESP_HEADER_IN_WORDS = 0x2;
-constexpr auto SBEI_SBE_RESPONSE_SIZE_IN_WORDS = ((sizeof(sbeRespHeader_t) + \
-        sizeof(sbe_word_t)) / 4);
 constexpr auto DISTANCE_TO_RESP_CODE = 0x1;
-
-std::vector<sbe_word_t> write(const char* devPath,
-                              const sbe_word_t* cmdBuffer,
-                              size_t cmdBufLen,
-                              size_t respBufLen)
+constexpr auto MAX_FFDC_LEN_IN_WORDS = 5120;
+constexpr auto WORD_SIZE = 4;
+constexpr auto MAGIC_CODE_BITS = 16;
+std::vector<sbe_word_t> writeToFifo(const char* devPath,
+                                    const sbe_word_t* cmdBuffer,
+                                    size_t cmdBufLen,
+                                    size_t respBufLen)
 {
-    //TODO: Add support for reading and writing from the FIFO device
-    std::vector<sbe_word_t> response(respBufLen);
+    size_t len = 0;
+    std::vector<sbe_word_t> response;
+    std::ostringstream errMsg;
+
+    //Open the device and obtain the file descriptor associated with it.
+    FileDescriptor fileFd(devPath, (O_RDWR | O_NONBLOCK));
+
+    //Wait for FIFO device and perform write operation
+    struct pollfd poll_fd = {};
+    poll_fd.fd = fileFd();
+    poll_fd.events = POLLOUT | POLLERR;
+
+    int rc = 0;
+    if ((rc = poll(&poll_fd, 1, -1)) < 0)
+    {
+        //TODO:use elog infrastructure
+        errMsg << "Waiting for FIFO device:" << devPath << "to write failed"
+               << "rc=" << rc << "errno=" << errno;
+        throw std::runtime_error(errMsg.str().c_str());
+    }
+    if (poll_fd.revents & POLLERR)
+    {
+        //TODO:use elog infrastructure
+        errMsg << "POLLERR while waiting for writeable FIFO,errno:" << errno;
+        throw std::runtime_error(errMsg.str().c_str());
+    }
+    auto bytesToWrite = (cmdBufLen * WORD_SIZE);
+    //Perform the write operation
+    len = write(fileFd(), cmdBuffer, bytesToWrite);
+    if (len < 0)
+    {
+        //TODO:use elog infrastructure
+        errMsg << "Failed to write to FIFO device:" << devPath << " Length "
+               "returned= " << len << " errno=" << errno;
+        throw std::runtime_error(errMsg.str().c_str());
+    }
+    //Wait for FIFO device and perform read operation
+    poll_fd.fd = fileFd();
+    poll_fd.events = POLLIN | POLLERR;
+    if ((rc = poll(&poll_fd, 1, -1) < 0))
+    {
+        //TODO:use elog infrastructure
+        errMsg << "Waiting for FIFO device:" << devPath << "to read failed"
+               << " rc=" << rc << " and errno=" << errno;
+        throw std::runtime_error(errMsg.str().c_str());
+    }
+    if (poll_fd.revents & POLLERR)
+    {
+        //TODO:use elog infrastructure
+        errMsg << "POLLERR while waiting for readable FIFO,errno:" << errno;
+        throw std::runtime_error(errMsg.str().c_str());
+    }
+    //Derive the total read length which should include the FFDC, which SBE
+    //returns in case of failure.
+    size_t totalReadLen = respBufLen + MAX_FFDC_LEN_IN_WORDS;
+    //Create a temporary buffer
+    std::vector<sbe_word_t> buffer(totalReadLen);
+
+    auto bytesToRead = (totalReadLen * WORD_SIZE);
+    len = read(fileFd(), buffer.data(), bytesToRead);
+    if (len < 0)
+    {
+        //TODO:use elog infrastructure
+        errMsg << "Failed to read the FIFO device:" << devPath << "bytes read ="
+               << len << " errno=" << errno;
+        throw std::runtime_error(errMsg.str().c_str());
+    }
+    else if (len != bytesToRead)
+    {
+        //TODO:use elog infrastructure
+        errMsg << "Exepcted " << bytesToRead << " bytes to be read from FIFO"
+               " device:" << devPath << ", but bytes read are " << len <<
+               " errno= " << errno;
+        throw std::runtime_error(errMsg.str().c_str());
+    }
+
+    //Extract the valid number of words read.
+    for (auto i = 0; i < (rc / WORD_SIZE); ++i)
+    {
+        response.push_back(be32toh(buffer[i]));
+    }
+
+    //Closing of the file descriptor will be handled when the FileDescriptor
+    //object will go out of scope.
     return response;
 }
 
-std::vector<sbe_word_t> parseResponse(
-    const std::vector<sbe_word_t>& sbeDataBuf)
+void parseResponse(std::vector<sbe_word_t>& sbeDataBuf)
 {
-
     //Number of 32-bit words obtained from the SBE
     size_t lengthObtained = sbeDataBuf.size();
 
@@ -62,22 +133,25 @@
     }
 
     //Fetch the response header contents
-    sbeRespHeader_t l_respHeader{};
     auto iter = sbeDataBuf.begin();
     std::advance(iter, (lengthObtained - distanceToStatusHeader));
-    l_respHeader.commandWord = *iter;
+
+    //First header word will have 2 bytes of MAGIC CODE followed by
+    //Command class and command type
+    //|  MAGIC BYTES:0xCODE | COMMAND-CLASS | COMMAND-TYPE|
+    sbe_word_t l_magicCode = (*iter >> MAGIC_CODE_BITS);
 
     //Fetch the primary and secondary response code
     std::advance(iter, DISTANCE_TO_RESP_CODE);
     auto l_priSecResp = *iter;
 
     //Validate the magic code obtained in the response
-    if (l_respHeader.magic != MAGIC_CODE)
+    if (l_magicCode != MAGIC_CODE)
     {
         //TODO:use elog infrastructure
         std::ostringstream errMsg;
         errMsg << "Invalid MAGIC keyword in the response header (" <<
-               l_respHeader.magic << "),expected keyword " << MAGIC_CODE;
+               l_magicCode << "),expected keyword " << MAGIC_CODE;
         throw std::runtime_error(errMsg.str().c_str());
     }
 
@@ -86,7 +160,7 @@
     {
         //Extract the SBE FFDC and throw it to the caller
         size_t ffdcLen = (distanceToStatusHeader -
-                          SBEI_SBE_RESPONSE_SIZE_IN_WORDS -
+                          LENGTH_OF_RESP_HEADER_IN_WORDS -
                           LENGTH_OF_DISTANCE_HEADER_IN_WORDS);
         if (ffdcLen)
         {
@@ -105,12 +179,15 @@
                << ".Length of FFDC data of obtained:" << ffdcLen;
         throw std::runtime_error(errMsg.str().c_str());
     }
-    return sbeDataBuf;
 
+    //In case of success, remove the response header content and send only the
+    //data.Response header will be towards the end of the buffer.
+    auto respLen = (lengthObtained - distanceToStatusHeader);
+    iter = sbeDataBuf.begin();
+    std::advance(iter,respLen);
+    sbeDataBuf.erase(iter, sbeDataBuf.end());
 }
 
 }
 }
 }
-
-
