On Wed, Aug 8, 2012 at 11:43 PM, trembl <
scoobi...@hotmail.com> wrote:
> Hello,
>
> I have a problem concerning the implementation of a communication between a
> node server and a device. I use the library net in node that provides a
> communication port type TCP client .
>
> code:
>
> var net = require('net');
>
> var HOSTPLC = '192.168.45.120'; //Adresse de l'appareil.
> var PORTPLC = 9600; //Port de communication.
>
> var client = new net.Socket();
>
>
>
> The problem is that when I send my string for the specific communication
> protocol to my device using eg:
>
> code:
>
> client.write(sFinsCmdRead);
>
>
> The function automatically adds unwanted values to each 16 hex value
> (observed using a network protocol analyzer) that just create an error in
> the interpreter of the device. The value is sent C2:
>
> eg:
>>
>>
>> 46:49:4e:53:00:00:00:1a:00:00:00:02:00:00:00:00:c2:80:00:02:00:78:00:00:ef:bf:bd:00:00:01:01:c2:82:00:64:00:00:01
>
>
> This imply error in the communication protocol.
>
> My questions: Is there a way to define the size of frames sent or otherwise
> eliminate the C2 value in the code? To do this, where do I look (in the
> code) ?
>
> The initial objective was to communicate directly between the device and
> page hml5 but as it is not possible, I use the server node client side to
> interact with the device. Is the basic idea is valid
> or is there better way to implement this ?
>
> Thank you all for your help.
You didn't tell what type sFinsCmdRead is but I suspect it's a string
and you're running into an encoding issue. Use a buffer instead.
The reason I think that is because I see a ef:bf:bd in there, which is
the UTF-8 encoding for U+FFFD, the 'invalid character' replacement.