Hi I Pant,
The idea that crossed my mind was to tie each of the lines coming from/going to "your device" to two of the DIO lines. Configure one these two ports as input, the other as output.
When you want to read the state of the line, read from the line configured as input. Similarly, use the other port when it is time to write.
Provided "your device" uses tri-state drivers/receivers, or can be used in a "wired-OR" configuration, this may work.
What is "your device"?
Ben