boB Gage wrote:
Hi,
Hi,
I am working on a MINA-based application that communicates with a
wide variety of manufacturers' devices, some are serial, others use
socket connections. All have been designed to be
transport-transparent, allowing us to simulate devices and specific
situations via socket-based simulator.
I added a CaptureLogFilter object to log data flow to a separate
file. I hook that object into the filter chain as each connection is
created.
Inside CaptureLogFilter, in both messageSent() and messageReceived()
hooks, I check the message parameter, and if it is an IoBuffer, I spit
out a capture line SENT (or RECEIVED) + # of bytes + a hex dump of those
bytes.
For simulated data sets (socket-based connections) this works great, my
capture log shows
SENT x bytes blah blah blah
SENT 0 bytes
RECEIVED y bytes blah blah blah
The extra "SENT 0 bytes" seemed odd but harmless.... until I noticed
what happens on serial connections. For those I invariably see:
The SENT 0 bytes is an artefact, produced in the encoder. It is used to
update some statistics. When the Head receive an IoBuffer with 0 bytes
in it, it assumes thaat a message has been sent, and increment the
associated counter. Obviously not the best way to count the number of
messages... Anyway. This is the reason you get this SENT 0 bytes.
SENT 0 bytes
RECEIVED y bytes blah blah blah
Each and every SENT line from a serial-based connection reads 0 bytes,
and I never see the actual command packet that I sent out. It seems
apparent that said data was received by the far end device, as the
RECEIVED lines show all the right responses, but my log only contains
half the conversation since all the SENT lines erroneously report "0
bytes."
I have no idea about why you don't get the number of sent bytes when
using the Serial-based connection. Julien ?
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org