TCP Client - Buffer Logic

HouseBot Plugin Development Discussions.
Post Reply
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

TCP Client - Buffer Logic

Post by Osler »

To Scott and anyone else with an interest:

I have written a TCP client plugin that allows for send and receive to an IP Address and Port. I plan on rolling this into a SageTV plugin that is used with the SageTCPServer, but wanted to put out a generic TCP client plug-in as well. So, the question is how to handle the data received? I am not a computer/network guru so I don't really have an understanding of how the buffer should work. With the SageTCPServer each data set is encapsulated between STX (0x02) and ETX (0x03). This means I can actually pick out each data set and present them one at a time via a property value. However, from my reading this seems to be somewhat non-standard for TCP communication. If I want to make a generic TCP client plug-in, how should the data be presented? Should it be based upon the size of the data (i.e., 128 characters have been received so present the data)? Should it just roll in as it's received, regardless of data length?

What are the criteria for presenting received data in the generic COM port plug-in? <To Scott>

How would others plan to use such a plug-in? What type of data would be received? Would you want the ability to toggle STX/ETX or Xon/Xoff as delimiters for the data received?

Osler
ScottBot
Site Admin
Posts: 2786
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: TCP Client - Buffer Logic

Post by ScottBot »

That's one of the big challenges in creating such a plugin. Although the TPC protocol is well defined, the data that is sent over the connection can really be in any format. Anything from human readable ASCII to esoteric binary data. Regardless it will be specific to some particular equipment and a challenge to generalize.

What I have done is to provide two different fields. One that contains the ascii value of the received data and the other that has a nicely parsed hex representation of the data. Most times the ascii won't be helpful, but the hex can always be deciphered even with binary protocols.

If you wanted to provide the same interfaces as the Generic Serial Module, you would need to write a hardware interface plugin. I don't think you can do it in vb. In that case, you would need to implement the 'SendSerialCommand()' interface and also provide the same subscription notification messages to send the received data to the devices. If you are serious about going down that path, I can give you more details.
Scott
Post Reply