Skip to content
Advertisement

Pipe not reading what it should

So I have 2 processes, a client who gets 2 operands and one operation (either + or -), sends them to the second process, the server, who makes the computation, then sends the result back to the client.

This is the client:

JavaScript


This is the server:

JavaScript

There are 3 outcomes to this code. First one is that it works, this is the least encountered case. Second one is that the data read from the server is not correct (I do a data check in the server). The first operand is read correctly but the sign and second operand are garbage values. Third case is that the operands and the sign are read correctly, but the result is again garbage. I don’t know why the third case even happens. So the data is correctly read, and my code that does the computation seems pretty straight forward and simple, but doesn’t work. I do a result check in the server before sending it back, and again, and it has garbage value. What aspect am I missing here?

Advertisement

Answer

The problem is probably, that all your communication is done via FIFO1, so your operands and the result get mixed up.

In the client you open FIFO1 for writing and reading and you write and read to it:

JavaScript

in the server it is the same:

JavaScript

so you end up with two listeners to FIFO1

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement