Binary Socket
D20980.022 Rev C
CV-LS User Manual
Page 81
Binary Socket
Socket Connection
The Binary Socket can be connected to using custom applications that allow for fast and robust
communications. The Dashboard Application uses the binary socket to enable live views and graphing at
high speed. The easiest way to start working with the Binary Socket is to look at the source code of the
Dashboard Application. This section of the manual describes some of the core functions used for this
interface, but is not meant as a sole source of information to be able to create an interface from.
Note:
Example code is copied from the Dashboard source code, and is written in C#.net.
Note:
Please reference the source code of the Dashboard Application and the Programming Guide for
supplemental information to create your own implementation of the Binary Socket.
Fletcher16 Checksums
The Flecher16 Checksum is used to determine if a packet is corrupted or not. There are many ways to
calculate the Flecher16 checksum, but this is the implementation used in the Dashboard Application:
// computes the fletcher16 checksum for the data[]
public
static
byte
[] fletcher16(
byte
[] data,
int
bytes)
{
UInt16
sum1 = 0xff, sum2 = 0xff;
int
tlen;
int
i = 0;
while
(bytes > 0)
{
tlen = bytes > 20 ? 20 : bytes;
bytes -= tlen;
do
{
sum2 += sum1 += data[i++];
}
while
(--tlen > 0);
/* First reduction step to reduce sums to 8 bits */
sum1 = (
UInt16
)((sum1 & 0xff) + (sum1 >> 8));
sum2 = (
UInt16
)((sum2 & 0xff) + (sum2 >> 8));
}
/* Second reduction step to reduce sums to 8 bits */
sum1 = (
UInt16
)((sum1 & 0xff) + (sum1 >> 8));
sum2 = (
UInt16
)((sum2 & 0xff) + (sum2 >> 8));
return
new
byte
[2] { (
byte
)sum2, (
byte
)(sum1) };
}
Содержание ColdVision
Страница 36: ...D20980 022 Rev C CV LS User Manual Page 36 LED LED UV UV LED RMA 91...
Страница 38: ...D20980 022 Rev C CV LS User Manual Page 38 1 SCHOTT SCHOTT machine vision moritex com...
Страница 42: ...D20980 022 Rev C CV LS User Manual Page 42 LED LED UV UV LED Return Material Authorization RMA 91...
Страница 44: ...D20980 022 Rev C CV LS User Manual Page 44 SCHOTT SCHOTT machine vision moritex com...