Echelon LonTal Stack Manual de usuario Pagina 228

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 247
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 227
216 Appendix G: Appendix G
Example LonTalk
Stack Applications
5. Runs a simple command console:
When the S command is pressed, sends a service pin messages from both
router halves by calling the sendServicePinMsg() method of the
LtIp852Router object.
When the E or Q command is pressed, breaks out of the console loop
6. On exit, does the following:
Shuts down the router by calling the Shutdown() method of the
LtIp852Router object.
Closes the native LonWorks network interface by deleting the
LtLogicalChannel object.
The main() function is shown below.
/* The main function just initializes the router and then runs a simple
command line interface. */
int main(int argc, char* argv[])
{
const char *pNiName = NULL;
int ipAddress;
int ipPort;
LtIp852Router router;
LtLtLogicalChannel *pLtChannel = NULL;
LtErrorType sts;
if (argc < 4 || sscanf(argv[3], "%d", &ipPort) != 1)
{
printf("Run an IP-852 to native LonTalk Router\n\n"
"Syntax:\n"
" Ip852Router <niName> <ipAddress> <ipPort>\n"
"\n"
" <niName> is the name of the native LonTalk network
interface\n"
" <ipAddress> is the IPv4 dotted-decimal address to use
for the IP-852\n"
" interface\n"
" <port> is a decimal port number to use for the
IP-852 interface\n"
"\n");
return 1;
}
else
{
pNiName = argv[1];
ipAddress = htonl(inet_addr(argv[2]));
}
pLtChannel = new LtLtLogicalChannel(pNiName);
sts = pLtChannel->getStartError();
if (sts == LT_NO_ERROR && !pLtChannel->getLonLink()->isOpen())
{
sts = LT_CANT_OPEN_PORT;
}
if (sts == LT_NO_ERROR)
{
#pragma message ("Warning: TBD - Must set a valid unique ID for IP-852
interface!!!")
const byte data[6] = { 0xBA, 0xDB, 0xAD, 0xBA, 0xD0, 0x00 };
LtUniqueId ltUid;
LtUniqueId ipUid(data);
pLtChannel->getLonLink()->getUniqueId(ltUid);
Vista de pagina 227
1 2 ... 223 224 225 226 227 228 229 230 231 232 233 ... 246 247

Comentarios a estos manuales

Sin comentarios