
Module: /home/henthorn/AUV/gnc-branch/auv-qnx/auv/altex/onboard/camera/XPort.cc
Group: 'DGROUP' CONST,CONST2,_DATA,_BSS

Segment: _TEXT  DWORD USE32  00000bfa bytes  

/** \file  XPort.cc */
/****************************************************************************/
/* Copyright (c) 2008 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : XPort.cc                                                      */
/* Author   : K Headley                                                     */
/* Project  : Benthic Imaging AUV                                           */
/* Created  : 04/01/2008                                                    */
/****************************************************************************/
/* Modification History:                                                    */
/*  $Id: XPort.cc,v 1.5.4.1 2016/05/19 18:28:57 headley Exp $   */
/*  $Name: gnc $ */
/****************************************************************************/

#include "XPort.h"
#include "qnx_port.h"
#include "Utils.h"
#include "BicamConsts.h"

/** Default no argument constructor. */
XPortCommand::XPortCommand(){}
/** Initializing constructor.
    Sets XPort GPIO command parameters.
    @param cmd Command byte
    @param p1 control mask
    @param p2 value mask
*/
 0000                    near XPortCommand::XPortCommand():
 0000  68 04 00 00 00                    push    00000004H
 0005  e8 00 00 00 00                    call    __CHK
 000a  c3                                ret     

XPortCommand::XPortCommand(unsigned char cmd,unsigned int p1,unsigned int p2){
 000b                    near XPortCommand::XPortCommand( char unsigned, int unsigned, int unsigned ):
 000b  68 08 00 00 00                    push    00000008H
 0010  e8 00 00 00 00                    call    __CHK
 0015  56                                push    esi
 0016  89 c6                             mov     esi,eax

  set(cmd,p1,p2);
 0018  81 e2 ff 00 00 00                 and     edx,000000ffH
 001e  e8 00 00 00 00                    call    void near XPortCommand::set( char unsigned, int unsigned, int unsigned )

}
/** Set XPort GPIO command parameters.
    \note Does not perform range checking
    @param cmd Command byte
    @param p1 control mask
    @param p2 value mask
*/
 0023  89 f0                             mov     eax,esi
 0025  5e                L1              pop     esi
 0026  c3                                ret     

void XPortCommand::set(unsigned char cmd,unsigned int p1,unsigned int p2){
  
 0027                    void near XPortCommand::set( char unsigned, int unsigned, int unsigned ):
 0027  68 04 00 00 00                    push    00000004H
 002c  e8 00 00 00 00                    call    __CHK

  command=0;
 0031  c6 00 00                          mov     byte ptr [eax],00H

  param1=0;
 0034  c7 40 01 00 00 00 
       00                                mov     dword ptr +1H[eax],00000000H

  param2=0;
  /* range checking here...*/
 003b  c7 40 05 00 00 00 
       00                                mov     dword ptr +5H[eax],00000000H

  command=cmd;
 0042  88 10                             mov     [eax],dl

  param1=(p1&0xffff);
  param2=(p2&0xffff);
  return;
 0044  81 e3 ff ff 00 00                 and     ebx,0000ffffH
 004a  89 58 01                          mov     +1H[eax],ebx

 004d  81 e1 ff ff 00 00                 and     ecx,0000ffffH
 0053  89 48 05                          mov     +5H[eax],ecx

}
/** @return command member variable */
 0056  c3                                ret     

unsigned char XPortCommand::getCommand(){
  return command;
 0057                    char unsigned near XPortCommand::getCommand():
 0057  68 04 00 00 00                    push    00000004H
 005c  e8 00 00 00 00                    call    __CHK

}
/** @return param1 member variable (control mask) */
 0061  8a 00                             mov     al,[eax]
 0063  c3                                ret     

unsigned int XPortCommand::getP1(){
  return param1;
 0064                    int unsigned near XPortCommand::getP1():
 0064  68 04 00 00 00                    push    00000004H
 0069  e8 00 00 00 00                    call    __CHK

}
/** @return param2 member variable (value mask) */
 006e  8b 40 01                          mov     eax,+1H[eax]
 0071  c3                                ret     

unsigned int XPortCommand::getP2(){
  return param2;
 0072                    int unsigned near XPortCommand::getP2():
 0072  68 04 00 00 00                    push    00000004H
 0077  e8 00 00 00 00                    call    __CHK

}
/** Validate command parameters. 
    Performs range checking on all parameters.
    @return OK if all parameters are valid, error code otherwise:
    - ERR_BADCMD: command parameter is invalid
    - ERR_BADPAR1: mask out of range
    - ERR_BADPAR2: mask out of range

    @see XPort.h
*/
 007c  8b 40 05                          mov     eax,+5H[eax]
 007f  c3                                ret     

int XPortCommand::validate(){
  if(command != XP_CMD_GET_FUNCTIONS &&
     command != XP_CMD_GET_DIRECTIONS &&
     command != XP_CMD_GET_ACTIVE_LEVELS &&
     command != XP_CMD_GET_CURRENT_STATES &&
     command != XP_CMD_SET_DIRECTIONS &&
     command != XP_CMD_SET_ACTIVE_LEVELS &&
 0080                    int near XPortCommand::validate():
 0080  68 08 00 00 00                    push    00000008H
 0085  e8 00 00 00 00                    call    __CHK
 008a  52                                push    edx
 008b  89 c2                             mov     edx,eax

     command != XP_CMD_SET_CURRENT_STATES &&
     command != XP_CMD_SEND_MESSAGE){
 008d  31 c0                             xor     eax,eax
 008f  8a 02                             mov     al,[edx]
 0091  83 f8 10                          cmp     eax,00000010H
 0094  74 2a                             je      L2
 0096  83 f8 11                          cmp     eax,00000011H
 0099  74 25                             je      L2
 009b  83 f8 12                          cmp     eax,00000012H
 009e  74 20                             je      L2
 00a0  83 f8 13                          cmp     eax,00000013H
 00a3  74 1b                             je      L2
 00a5  83 f8 19                          cmp     eax,00000019H
 00a8  74 16                             je      L2
 00aa  83 f8 1a                          cmp     eax,0000001aH
 00ad  74 11                             je      L2
 00af  83 f8 1b                          cmp     eax,0000001bH
 00b2  74 0c                             je      L2
 00b4  83 f8 7f                          cmp     eax,0000007fH
 00b7  74 07                             je      L2

    return ERR_BADCMD;
  }
 00b9  b8 fe ff ff ff                    mov     eax,0fffffffeH
 00be  5a                                pop     edx
 00bf  c3                                ret     

  if( param1>(unsigned)0xffff ){
 00c0  81 7a 01 ff ff 00 
       00                L2              cmp     dword ptr +1H[edx],0000ffffH
 00c7  76 07                             jbe     L3

    return ERR_BADPAR1;
  }
 00c9  b8 fd ff ff ff                    mov     eax,0fffffffdH
 00ce  5a                                pop     edx
 00cf  c3                                ret     

  if( param2>(unsigned)0xffff ){
 00d0  81 7a 05 ff ff 00 
       00                L3              cmp     dword ptr +5H[edx],0000ffffH
 00d7  76 07                             jbe     L4

    return ERR_BADPAR2;
  }

 00d9  b8 fc ff ff ff                    mov     eax,0fffffffcH
 00de  5a                                pop     edx
 00df  c3                                ret     

  return IS_VALID;

 00e0  31 c0             L4              xor     eax,eax

}
/** Populate this XPCommand from a (binary) byte array. 
    @param cmd Byte buffer containing command bytes
*/
 00e2  5a                                pop     edx
 00e3  c3                                ret     

int XPortCommand::parse(const char *cmd){

 00e4                    int near XPortCommand::parse( char const near * ):
 00e4  68 10 00 00 00                    push    00000010H
 00e9  e8 00 00 00 00                    call    __CHK
 00ee  53                                push    ebx
 00ef  51                                push    ecx
 00f0  56                                push    esi
 00f1  89 c1                             mov     ecx,eax
 00f3  89 d6                             mov     esi,edx

  memcpy(&command,&cmd[0],XP_CMD_LEN);
 00f5  bb 01 00 00 00                    mov     ebx,00000001H
 00fa  e8 00 00 00 00                    call    memcpy_

  memcpy(&param1,&cmd[1],XP_PARAM_LEN);
 00ff  8d 56 01                          lea     edx,+1H[esi]
 0102  8d 41 01                          lea     eax,+1H[ecx]
 0105  bb 04 00 00 00                    mov     ebx,00000004H
 010a  e8 00 00 00 00                    call    memcpy_

  memcpy(&param2,&cmd[5],XP_PARAM_LEN);

 010f  8d 56 05                          lea     edx,+5H[esi]
 0112  8d 41 05                          lea     eax,+5H[ecx]
 0115  bb 04 00 00 00                    mov     ebx,00000004H
 011a  e8 00 00 00 00                    call    memcpy_

  return validate();
 011f  89 c8                             mov     eax,ecx
 0121  e8 00 00 00 00                    call    int near XPortCommand::validate()

}
/** Format XPort command and print to console.
    \note Requires that DEBUG be enabled
*/
 0126  5e                                pop     esi
 0127  59                                pop     ecx
 0128  5b                                pop     ebx
 0129  c3                                ret     

void XPortCommand::show(){
#ifdef DEBUG
  printdbg(" cmd: %02x %02x %02x\n",command,param1,param2);
#endif
  return ;
 012a                    void near XPortCommand::show():
 012a  68 04 00 00 00                    push    00000004H
 012f  e8 00 00 00 00                    call    __CHK

}
/** Writes XPort GPIO command bytes to specified buffer.
    \note Buffer should have length >= (XP_CMD_LEN+2*XP_PARAM_LEN)
    @param buf Byte buffer 
    @return pointer to buffer
*/
 0134  c3                                ret     

char *XPortCommand::toBytes(char *buf){
 0135                    char near * near XPortCommand::toBytes( char near * ):
 0135  68 10 00 00 00                    push    00000010H
 013a  e8 00 00 00 00                    call    __CHK
 013f  53                                push    ebx
 0140  51                                push    ecx
 0141  56                                push    esi
 0142  89 c6                             mov     esi,eax
 0144  89 d1                             mov     ecx,edx

  memcpy(&buf[0],&command,XP_CMD_LEN);
 0146  bb 01 00 00 00                    mov     ebx,00000001H
 014b  89 c2                             mov     edx,eax
 014d  89 c8                             mov     eax,ecx
 014f  e8 00 00 00 00                    call    memcpy_

  memcpy(&buf[1],&param1,XP_PARAM_LEN);
 0154  8d 56 01                          lea     edx,+1H[esi]
 0157  8d 41 01                          lea     eax,+1H[ecx]
 015a  bb 04 00 00 00                    mov     ebx,00000004H
 015f  e8 00 00 00 00                    call    memcpy_

  memcpy(&buf[5],&param2,XP_PARAM_LEN);
  return buf;
 0164  8d 56 05                          lea     edx,+5H[esi]
 0167  8d 41 05                          lea     eax,+5H[ecx]
 016a  bb 04 00 00 00    L5              mov     ebx,00000004H
 016f  e8 00 00 00 00                    call    memcpy_

}
/** output stream operator.
    Formats object for output stream insertion
    @param output output stream handle
    @param n XPortCommand object pointer
*/
 0174  89 c8                             mov     eax,ecx
 0176  5e                                pop     esi
 0177  59                                pop     ecx
 0178  5b                                pop     ebx
 0179  c3                                ret     

ostream& operator<<(ostream& output, const XPortCommand& n){
 017a                    ostream near & near operator <<( ostream near &, XPortCommand const near & ):
 017a  68 48 00 00 00                    push    00000048H
 017f  e8 00 00 00 00                    call    __CHK
 0184  53                                push    ebx
 0185  51                                push    ecx
 0186  83 ec 3c                          sub     esp,0000003cH
 0189  89 d3                             mov     ebx,edx

  cout << "{0x"<<hex<<setiosflags(ios::fixed)<<setfill('0')<<setw(2)<<(unsigned int)n.command<<",0x"<<setw(2)<<n.param1<<",0x"<<setw(2)<<n.param2<<"}";
  return cout;
 018b  8d 44 24 20                       lea     eax,+20H[esp]
 018f  89 44 24 28                       mov     +28H[esp],eax
 0193  a1 00 00 00 00                    mov     eax,<int near >::sapp near setw
 0198  89 44 24 20                       mov     +20H[esp],eax
 019c  c7 44 24 24 02 00 
       00 00                             mov     dword ptr +24H[esp],00000002H
 01a4  8d 54 24 18                       lea     edx,+18H[esp]
 01a8  89 54 24 2c                       mov     +2cH[esp],edx
 01ac  89 44 24 18                       mov     +18H[esp],eax
 01b0  c7 44 24 1c 02 00 
       00 00                             mov     dword ptr +1cH[esp],00000002H
 01b8  31 c9                             xor     ecx,ecx
 01ba  8a 0b                             mov     cl,[ebx]
 01bc  89 e2                             mov     edx,esp
 01be  89 54 24 30                       mov     +30H[esp],edx
 01c2  89 04 24                          mov     [esp],eax
 01c5  c7 44 24 04 02 00 
       00 00                             mov     dword ptr +4H[esp],00000002H
 01cd  8d 44 24 10                       lea     eax,+10H[esp]
 01d1  89 44 24 34                       mov     +34H[esp],eax
 01d5  a1 00 00 00 00                    mov     eax,<int near >::sapp near setfill
 01da  89 44 24 10                       mov     +10H[esp],eax
 01de  c7 44 24 14 30 00 
       00 00                             mov     dword ptr +14H[esp],00000030H
 01e6  8d 44 24 08                       lea     eax,+8H[esp]
 01ea  89 44 24 38                       mov     +38H[esp],eax
 01ee  a1 00 00 00 00                    mov     eax,<long near >::sapp near setiosflags
 01f3  89 44 24 08                       mov     +8H[esp],eax
 01f7  c7 44 24 0c 00 10 
       00 00                             mov     dword ptr +0cH[esp],00001000H
 01ff  ba 0a 00 00 00                    mov     edx,offset L41
 0204  b8 00 00 00 00                    mov     eax,offset ostream near cout
 0209  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 020e  ba 00 00 00 00                    mov     edx,offset ios near & near hex( ios near & )
 0213  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ios near & (near *)( ))
 0218  8d 54 24 08                       lea     edx,+8H[esp]
 021c  e8 00 00 00 00                    call    ostream near & near operator <<( ostream near &, <long near >::smanip const near & )
 0221  8d 54 24 10                       lea     edx,+10H[esp]
 0225  e8 00 00 00 00                    call    ostream near & near operator <<( ostream near &, <int near >::smanip const near & )
 022a  89 e2                             mov     edx,esp
 022c  e8 00 00 00 00                    call    ostream near & near operator <<( ostream near &, <int near >::smanip const near & )
 0231  89 ca                             mov     edx,ecx
 0233  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long unsigned )
 0238  ba 06 00 00 00                    mov     edx,offset L40
 023d  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0242  8d 54 24 18                       lea     edx,+18H[esp]
 0246  e8 00 00 00 00                    call    ostream near & near operator <<( ostream near &, <int near >::smanip const near & )
 024b  8b 53 01                          mov     edx,+1H[ebx]
 024e  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long unsigned )
 0253  ba 02 00 00 00                    mov     edx,offset L39
 0258  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 025d  8d 54 24 20                       lea     edx,+20H[esp]
 0261  e8 00 00 00 00                    call    ostream near & near operator <<( ostream near &, <int near >::smanip const near & )
 0266  8b 53 05                          mov     edx,+5H[ebx]
 0269  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long unsigned )
 026e  ba 00 00 00 00                    mov     edx,offset L38
 0273  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )

}

/** Default no argument constructor. */
 0278  b8 00 00 00 00                    mov     eax,offset ostream near cout
 027d  83 c4 3c                          add     esp,0000003cH
 0280  59                                pop     ecx
 0281  5b                                pop     ebx
 0282  c3                                ret     

XPortResponse::XPortResponse(){}
/** Initializing constructor.
    Sets XPort GPIO response parameters.
    @param cmd Command byte
    @param p1 control mask
*/
 0283                    near XPortResponse::XPortResponse():
 0283  68 04 00 00 00                    push    00000004H
 0288  e8 00 00 00 00                    call    __CHK
 028d  c3                                ret     

XPortResponse::XPortResponse(unsigned char cmd,unsigned int p1){
 028e                    near XPortResponse::XPortResponse( char unsigned, int unsigned ):
 028e  68 08 00 00 00                    push    00000008H
 0293  e8 00 00 00 00                    call    __CHK
 0298  51                                push    ecx
 0299  89 c1                             mov     ecx,eax

  set(cmd,p1);
 029b  81 e2 ff 00 00 00                 and     edx,000000ffH
 02a1  e8 00 00 00 00                    call    void near XPortResponse::set( char unsigned, int unsigned )

}
/** Set XPort GPIO response parameters.
    \note Does not perform range checking
    @param cmd Command byte
    @param p1 control mask
*/
 02a6  89 c8                             mov     eax,ecx
 02a8  59                                pop     ecx
 02a9  c3                                ret     

void XPortResponse::set(unsigned char cmd,unsigned int p1){
 02aa                    void near XPortResponse::set( char unsigned, int unsigned ):
 02aa  68 04 00 00 00                    push    00000004H
 02af  e8 00 00 00 00                    call    __CHK

  command=0;
 02b4  c6 00 00                          mov     byte ptr [eax],00H

  param1=0;
  /* range checking here...*/
 02b7  c7 40 01 00 00 00 
       00                                mov     dword ptr +1H[eax],00000000H

  command=cmd;
  param1=(p1&0xffff);
  return;
 02be  88 10                             mov     [eax],dl

 02c0  81 e3 ff ff 00 00                 and     ebx,0000ffffH
 02c6  89 58 01                          mov     +1H[eax],ebx

}
/** Validate response parameters. 
    Performs range checking on all parameters.
    @return OK if all parameters are valid, error code otherwise:
    - ERR_BADCMD: command parameter is invalid
    - ERR_BADPAR1: mask out of range

    @see XPort.h
*/
 02c9  c3                                ret     

int XPortResponse::validate(){

  if(command != XP_CMD_GET_FUNCTIONS &&
     command != XP_CMD_GET_DIRECTIONS &&
     command != XP_CMD_GET_ACTIVE_LEVELS &&
     command != XP_CMD_GET_CURRENT_STATES &&
     command != XP_CMD_SET_DIRECTIONS &&
     command != XP_CMD_SET_ACTIVE_LEVELS &&
 02ca                    int near XPortResponse::validate():
 02ca  68 08 00 00 00                    push    00000008H
 02cf  e8 00 00 00 00                    call    __CHK
 02d4  52                                push    edx
 02d5  89 c2                             mov     edx,eax

     command != XP_CMD_SET_CURRENT_STATES &&
     command != XP_CMD_SEND_MESSAGE){
 02d7  31 c0                             xor     eax,eax
 02d9  8a 02                             mov     al,[edx]
 02db  83 f8 10                          cmp     eax,00000010H
 02de  74 2a                             je      L6
 02e0  83 f8 11                          cmp     eax,00000011H
 02e3  74 25                             je      L6
 02e5  83 f8 12                          cmp     eax,00000012H
 02e8  74 20                             je      L6
 02ea  83 f8 13                          cmp     eax,00000013H
 02ed  74 1b                             je      L6
 02ef  83 f8 19                          cmp     eax,00000019H
 02f2  74 16                             je      L6
 02f4  83 f8 1a                          cmp     eax,0000001aH
 02f7  74 11                             je      L6
 02f9  83 f8 1b                          cmp     eax,0000001bH
 02fc  74 0c                             je      L6
 02fe  83 f8 7f                          cmp     eax,0000007fH
 0301  74 07                             je      L6

    return ERR_BADCMD;
  }

 0303  b8 fe ff ff ff                    mov     eax,0fffffffeH
 0308  5a                                pop     edx
 0309  c3                                ret     

  if( param1>(unsigned)0xffff ){
 030a  81 7a 01 ff ff 00 
       00                L6              cmp     dword ptr +1H[edx],0000ffffH
 0311  76 07                             jbe     L7

    return ERR_BADPAR1;
  }

 0313  b8 fd ff ff ff                    mov     eax,0fffffffdH
 0318  5a                                pop     edx
 0319  c3                                ret     

  return IS_VALID;
 031a  31 c0             L7              xor     eax,eax

}

/** Populate this XPResponse from a (binary) byte array. 
    @param response Byte buffer containing response bytes
*/
 031c  5a                                pop     edx
 031d  c3                                ret     

int XPortResponse::parse(char *response){
 031e                    int near XPortResponse::parse( char near * ):
 031e  68 10 00 00 00                    push    00000010H
 0323  e8 00 00 00 00                    call    __CHK
 0328  53                                push    ebx
 0329  51                                push    ecx
 032a  56                                push    esi
 032b  89 c1                             mov     ecx,eax
 032d  89 d6                             mov     esi,edx

  memcpy(&command,&response[0],XP_CMD_LEN);
 032f  bb 01 00 00 00                    mov     ebx,00000001H
 0334  e8 00 00 00 00                    call    memcpy_

  memcpy(&param1,&response[1],XP_PARAM_LEN);
 0339  8d 56 01                          lea     edx,+1H[esi]
 033c  8d 41 01                          lea     eax,+1H[ecx]
 033f  bb 04 00 00 00                    mov     ebx,00000004H
 0344  e8 00 00 00 00                    call    memcpy_

  return validate();
 0349  89 c8                             mov     eax,ecx
 034b  e8 00 00 00 00                    call    int near XPortResponse::validate()

}
/** Format XPort response and print to console.
    \note Requires that DEBUG be enabled
*/
 0350  5e                                pop     esi
 0351  59                                pop     ecx
 0352  5b                                pop     ebx
 0353  c3                                ret     

void XPortResponse::show(){
#ifdef DEBUG
  printdbg(" res: %02x %02x\n",command,param1);
#endif
  return;
 0354                    void near XPortResponse::show():
 0354  68 04 00 00 00                    push    00000004H
 0359  e8 00 00 00 00                    call    __CHK

}
/** @return command member variable */
 035e  c3                                ret     

unsigned char XPortResponse::getCommand(){
  return command;
 035f                    char unsigned near XPortResponse::getCommand():
 035f  68 04 00 00 00                    push    00000004H
 0364  e8 00 00 00 00                    call    __CHK

}
/** @return param1 member variable (control mask) */
 0369  8a 00                             mov     al,[eax]
 036b  c3                                ret     

unsigned int XPortResponse::getP1(){
  return param1;
 036c                    int unsigned near XPortResponse::getP1():
 036c  68 04 00 00 00                    push    00000004H
 0371  e8 00 00 00 00                    call    __CHK

}
/** Writes XPort GPIO response bytes to specified buffer.
    \note Buffer should have length >= (XP_CMD_LEN+XP_PARAM_LEN)
    @param buf Byte buffer 
    @return pointer to buffer
*/
 0376  8b 40 01                          mov     eax,+1H[eax]
 0379  c3                                ret     

char *XPortResponse::toBytes(char *buf){
 037a                    char near * near XPortResponse::toBytes( char near * ):
 037a  68 10 00 00 00                    push    00000010H
 037f  e8 00 00 00 00                    call    __CHK
 0384  53                                push    ebx
 0385  51                                push    ecx
 0386  56                                push    esi
 0387  89 c6                             mov     esi,eax
 0389  89 d1                             mov     ecx,edx

  memcpy(&buf[0],&command,XP_CMD_LEN);
 038b  bb 01 00 00 00                    mov     ebx,00000001H
 0390  89 c2                             mov     edx,eax
 0392  89 c8                             mov     eax,ecx
 0394  e8 00 00 00 00                    call    memcpy_

  memcpy(&buf[1],&param1,XP_PARAM_LEN);
  return buf;
}

/** output stream operator.
    Formats object for output stream insertion
    @param output output stream handle
    @param n XPortResponse object pointer
*/
 0399  8d 56 01                          lea     edx,+1H[esi]
 039c  8d 41 01                          lea     eax,+1H[ecx]
 039f  e9 c6 fd ff ff                    jmp     L5

ostream& operator<<(ostream& output, const XPortResponse& n){
 03a4                    ostream near & near operator <<( ostream near &, XPortResponse const near & ):
 03a4  68 3c 00 00 00                    push    0000003cH
 03a9  e8 00 00 00 00                    call    __CHK
 03ae  53                                push    ebx
 03af  51                                push    ecx
 03b0  83 ec 30                          sub     esp,00000030H
 03b3  89 d3                             mov     ebx,edx

  cout << "{"<<hex<<setiosflags(ios::fixed)<<setfill('0')<<setw(2)<<(unsigned int)n.command<<",0x"<<setw(2)<<n.param1<<"}";
  return cout;
 03b5  8d 44 24 10                       lea     eax,+10H[esp]
 03b9  89 44 24 20                       mov     +20H[esp],eax
 03bd  a1 00 00 00 00                    mov     eax,<int near >::sapp near setw
 03c2  89 44 24 10                       mov     +10H[esp],eax
 03c6  c7 44 24 14 02 00 
       00 00                             mov     dword ptr +14H[esp],00000002H
 03ce  31 c9                             xor     ecx,ecx
 03d0  8a 0b                             mov     cl,[ebx]
 03d2  8d 54 24 18                       lea     edx,+18H[esp]
 03d6  89 54 24 24                       mov     +24H[esp],edx
 03da  89 44 24 18                       mov     +18H[esp],eax
 03de  c7 44 24 1c 02 00 
       00 00                             mov     dword ptr +1cH[esp],00000002H
 03e6  8d 44 24 08                       lea     eax,+8H[esp]
 03ea  89 44 24 28                       mov     +28H[esp],eax
 03ee  a1 00 00 00 00                    mov     eax,<int near >::sapp near setfill
 03f3  89 44 24 08                       mov     +8H[esp],eax
 03f7  c7 44 24 0c 30 00 
       00 00                             mov     dword ptr +0cH[esp],00000030H
 03ff  89 e0                             mov     eax,esp
 0401  89 44 24 2c                       mov     +2cH[esp],eax
 0405  a1 00 00 00 00                    mov     eax,<long near >::sapp near setiosflags
 040a  89 04 24                          mov     [esp],eax
 040d  c7 44 24 04 00 10 
       00 00                             mov     dword ptr +4H[esp],00001000H
 0415  ba 14 00 00 00                    mov     edx,offset L44
 041a  b8 00 00 00 00                    mov     eax,offset ostream near cout
 041f  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0424  ba 00 00 00 00                    mov     edx,offset ios near & near hex( ios near & )
 0429  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ios near & (near *)( ))
 042e  89 e2                             mov     edx,esp
 0430  e8 00 00 00 00                    call    ostream near & near operator <<( ostream near &, <long near >::smanip const near & )
 0435  8d 54 24 08                       lea     edx,+8H[esp]
 0439  e8 00 00 00 00                    call    ostream near & near operator <<( ostream near &, <int near >::smanip const near & )
 043e  8d 54 24 18                       lea     edx,+18H[esp]
 0442  e8 00 00 00 00                    call    ostream near & near operator <<( ostream near &, <int near >::smanip const near & )
 0447  89 ca                             mov     edx,ecx
 0449  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long unsigned )
 044e  ba 10 00 00 00                    mov     edx,offset L43
 0453  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0458  8d 54 24 10                       lea     edx,+10H[esp]
 045c  e8 00 00 00 00                    call    ostream near & near operator <<( ostream near &, <int near >::smanip const near & )
 0461  8b 53 01                          mov     edx,+1H[ebx]
 0464  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long unsigned )
 0469  ba 0e 00 00 00                    mov     edx,offset L42
 046e  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )

}

/** Default no argument constructor. */
XPortConnection::XPortConnection(){}
/** Initializing constructor.
    @param host XPort host name
    @param gpioIPPort TCP/IP port to use for GPIO
    @param serialIPPort TCP/IP port to use for serial IO
    @param dirMask GPIO direction pin-select mask
    @param dirValues GPIO initial direction values mask
    @param levelMask GPIO level pin-select mask
    @param levelValues GPIO initial level (state) values mask
*/
 0473  b8 00 00 00 00                    mov     eax,offset ostream near cout
 0478  83 c4 30                          add     esp,00000030H
 047b  59                                pop     ecx
 047c  5b                                pop     ebx
 047d  c3                                ret     

XPortConnection::XPortConnection(char *host, 
				 unsigned int gpioIPPort, 
				 unsigned int serialIPPort,
				 unsigned int dirMask,
				 unsigned int dirValues,
				 unsigned int levelMask,
				 unsigned int levelValues){
 047e                    near XPortConnection::XPortConnection( char near *, int unsigned, int unsigned, int unsigned, int unsigned, int unsigned, int unsigned ):
 047e  68 10 00 00 00                    push    00000010H
 0483  e8 00 00 00 00                    call    __CHK
 0488  56                                push    esi
 0489  89 c6                             mov     esi,eax

  configHost(host);
 048b  e8 00 00 00 00                    call    int near XPortConnection::configHost( char near * )

  configGPIO(gpioPort,dirMask,dirValues,levelMask,levelValues);
 0490  8b 54 24 14                       mov     edx,+14H[esp]
 0494  52                                push    edx
 0495  8b 5c 24 14                       mov     ebx,+14H[esp]
 0499  53                                push    ebx
 049a  8b 56 04                          mov     edx,+4H[esi]
 049d  8b 4c 24 14                       mov     ecx,+14H[esp]
 04a1  8b 5c 24 10                       mov     ebx,+10H[esp]
 04a5  89 f0                             mov     eax,esi
 04a7  e8 00 00 00 00                    call    int near XPortConnection::configGPIO( int, int unsigned, int unsigned, int unsigned, int unsigned )

  configSerial(serialPort);
 04ac  8b 56 08                          mov     edx,+8H[esi]
 04af  89 f0                             mov     eax,esi
 04b1  e8 00 00 00 00                    call    int near XPortConnection::configSerial( int )

}
/** Configure all connection parameters
    @param host XPort host name
    @param gpioIPPort TCP/IP port to use for GPIO
    @param serialIPPort TCP/IP port to use for serial IO
    @param dirMask GPIO direction pin-select mask
    @param dirValues GPIO initial direction values mask
    @param levelMask GPIO level pin-select mask
    @param levelValues GPIO initial level (state) values mask
    @return OK;
*/
 04b6  89 f0                             mov     eax,esi
 04b8  5e                                pop     esi
 04b9  c2 10 00                          ret     0010H

int XPortConnection::configAll( char *host, 
			   unsigned int gpioIPPort, 
			   unsigned int serialIPPort,
			   unsigned int dirMask,
			   unsigned int dirValues,
			   unsigned int levelMask,
			   unsigned int levelValues){
 04bc                    int near XPortConnection::configAll( char near *, int unsigned, int unsigned, int unsigned, int unsigned, int unsigned, int unsigned ):
 04bc  68 18 00 00 00                    push    00000018H
 04c1  e8 00 00 00 00                    call    __CHK
 04c6  56                                push    esi
 04c7  57                                push    edi
 04c8  55                                push    ebp
 04c9  89 c6                             mov     esi,eax
 04cb  89 df                             mov     edi,ebx
 04cd  89 cd                             mov     ebp,ecx

  configHost(host);
 04cf  e8 00 00 00 00                    call    int near XPortConnection::configHost( char near * )

  configGPIO(gpioIPPort,dirMask,dirValues,levelMask,levelValues);
 04d4  8b 54 24 1c                       mov     edx,+1cH[esp]
 04d8  52                                push    edx
 04d9  8b 5c 24 1c                       mov     ebx,+1cH[esp]
 04dd  53                                push    ebx
 04de  8b 4c 24 1c                       mov     ecx,+1cH[esp]
 04e2  8b 5c 24 18                       mov     ebx,+18H[esp]
 04e6  89 fa                             mov     edx,edi
 04e8  89 f0                             mov     eax,esi
 04ea  e8 00 00 00 00                    call    int near XPortConnection::configGPIO( int, int unsigned, int unsigned, int unsigned, int unsigned )

  configSerial(serialIPPort);

  //cout<<"configAll: {"<<host<<","<<gpioPort<<","<<serialPort<<",";
  //cout<<dirMask<<","<<dirValues<<",";
  //cout<<levelMask<<","<<levelValues<<"}"<<endl;
  return OK;
 04ef  89 ea                             mov     edx,ebp
 04f1  89 f0                             mov     eax,esi
 04f3  e8 00 00 00 00                    call    int near XPortConnection::configSerial( int )

}
/** Configure host TCP/IP address
    @param hostName XPort host name
    @return OK;
*/
 04f8  31 c0             L8              xor     eax,eax
 04fa  5d                L9              pop     ebp
 04fb  5f                                pop     edi
 04fc  5e                                pop     esi
 04fd  c2 10 00                          ret     0010H

int XPortConnection::configHost( char *hostName){
 0500                    int near XPortConnection::configHost( char near * ):
 0500  68 04 00 00 00                    push    00000004H
 0505  e8 00 00 00 00                    call    __CHK

  host=hostName;
  return OK;
 050a  89 10                             mov     [eax],edx

}
/** Configure GPIO connection parameters
    @param gPort TCP/IP port to use for GPIO
    @param dMask GPIO direction pin-select mask
    @param dValues GPIO initial direction values mask
    @param lMask GPIO level pin-select mask
    @param lValues GPIO initial level (state) values mask
    @return OK;
*/
 050c  31 c0                             xor     eax,eax
 050e  c3                                ret     

int XPortConnection::configGPIO( int gPort, 
			   unsigned int dMask,
			   unsigned int dValues,
			   unsigned int lMask,
			   unsigned int lValues){
 050f                    int near XPortConnection::configGPIO( int, int unsigned, int unsigned, int unsigned, int unsigned ):
 050f  68 04 00 00 00                    push    00000004H
 0514  e8 00 00 00 00                    call    __CHK

  gpioPort=gPort;
 0519  89 50 04                          mov     +4H[eax],edx

  dirMask=dMask;
 051c  89 58 0c                          mov     +0cH[eax],ebx

  levelMask=lMask;
 051f  8b 54 24 04                       mov     edx,+4H[esp]
 0523  89 50 10                          mov     +10H[eax],edx

  dirValues=dValues;
 0526  89 48 14                          mov     +14H[eax],ecx

  levelValues=lValues;
  return OK;
 0529  8b 54 24 08                       mov     edx,+8H[esp]
 052d  89 50 18                          mov     +18H[eax],edx

}
/** Configure serial TCP/IP port parameters
    @param sPort TCP/IP port to use for serial IO
    @return OK;
*/
 0530  31 c0                             xor     eax,eax
 0532  c2 08 00                          ret     0008H

int XPortConnection::configSerial( int sPort){
 0535                    int near XPortConnection::configSerial( int ):
 0535  68 04 00 00 00                    push    00000004H
 053a  e8 00 00 00 00                    call    __CHK

  serialPort=sPort;
  return OK;
 053f  89 50 08                          mov     +8H[eax],edx

}
/** Set GPIO socket descriptor. 
    @param sd socket descriptor
*/
 0542  31 c0                             xor     eax,eax
 0544  c3                                ret     

void XPortConnection::setsdGPIO(int sd){
 0545                    void near XPortConnection::setsdGPIO( int ):
 0545  68 04 00 00 00                    push    00000004H
 054a  e8 00 00 00 00                    call    __CHK

  sdGPIO=sd;
 054f  89 50 1c                          mov     +1cH[eax],edx

}
/** Set serial socket descriptor. 
    @param sd socket descriptor
*/
 0552  c3                                ret     

void XPortConnection::setsdSerial(int sd){
 0553                    void near XPortConnection::setsdSerial( int ):
 0553  68 04 00 00 00                    push    00000004H
 0558  e8 00 00 00 00                    call    __CHK

  sdSERIAL=sd;
 055d  89 50 20                          mov     +20H[eax],edx

}
/** @return XPort host TCP/IP address/name */
 char *XPortConnection::getHost(){
  return host;
}
/** @return GPIO TCP/IP port */
unsigned int XPortConnection::getpGPIO(){
  return gpioPort;
}
/** @return Serial TCP/IP port */
unsigned int XPortConnection::getpSerial(){
  return serialPort;
}
/** @return GPIO TCP/IP socket descriptor */
int XPortConnection::getsdGPIO(){
  return sdGPIO;
}
/** @return Serial TCP/IP socket descriptor */
int XPortConnection::getsdSerial(){
  return sdSERIAL;
}
/** @return GPIO pin direction control mask */
 0560  c3                                ret     

unsigned int XPortConnection::getDirMask(){return dirMask;}
/** @return GPIO pin direction values mask */
 0561                    int unsigned near XPortConnection::getDirMask():
 0561  68 04 00 00 00                    push    00000004H
 0566  e8 00 00 00 00                    call    __CHK
 056b  8b 40 0c                          mov     eax,+0cH[eax]
 056e  c3                                ret     

unsigned int XPortConnection::getDirValues(){return dirValues;}
/** @return GPIO pin level control mask */
 056f                    int unsigned near XPortConnection::getDirValues():
 056f  68 04 00 00 00                    push    00000004H
 0574  e8 00 00 00 00                    call    __CHK
 0579  8b 40 14                          mov     eax,+14H[eax]
 057c  c3                                ret     

unsigned int XPortConnection::getLevelMask(){return levelMask;}
/** @return GPIO pin level values mask */
 057d                    int unsigned near XPortConnection::getLevelMask():
 057d  68 04 00 00 00                    push    00000004H
 0582  e8 00 00 00 00                    call    __CHK
 0587  8b 40 10                          mov     eax,+10H[eax]
 058a  c3                                ret     

unsigned int XPortConnection::getLevelValues(){return levelValues;}


/** output stream operator.
    Formats object for output stream insertion
    @param output output stream handle
    @param n Field object pointer
*/
 058b                    int unsigned near XPortConnection::getLevelValues():
 058b  68 04 00 00 00                    push    00000004H
 0590  e8 00 00 00 00                    call    __CHK
 0595  8b 40 18                          mov     eax,+18H[eax]
 0598  c3                                ret     

ostream& operator<<(ostream& output, const XPortConnection& n){

 0599                    ostream near & near operator <<( ostream near &, XPortConnection const near & ):
 0599  68 0c 00 00 00                    push    0000000cH
 059e  e8 00 00 00 00                    call    __CHK
 05a3  53                                push    ebx
 05a4  51                                push    ecx
 05a5  89 d3                             mov     ebx,edx

  cout << "{"<<endl<<" host:" << n.host <<endl;
 05a7  8b 0a                             mov     ecx,[edx]
 05a9  ba 1d 00 00 00                    mov     edx,offset L46
 05ae  b8 00 00 00 00                    mov     eax,offset ostream near cout
 05b3  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 05b8  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 05bd  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))
 05c2  ba 16 00 00 00                    mov     edx,offset L45
 05c7  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 05cc  89 ca                             mov     edx,ecx
 05ce  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 05d3  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 05d8  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

  cout << " gpioPort:0x" << hex << n.gpioPort << " serialPort: "<<dec<<n.serialPort <<endl;
 05dd  ba 2d 00 00 00                    mov     edx,offset L48
 05e2  b8 00 00 00 00                    mov     eax,offset ostream near cout
 05e7  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 05ec  ba 00 00 00 00                    mov     edx,offset ios near & near hex( ios near & )
 05f1  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ios near & (near *)( ))
 05f6  8b 53 04                          mov     edx,+4H[ebx]
 05f9  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long )
 05fe  ba 1f 00 00 00                    mov     edx,offset L47
 0603  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0608  ba 00 00 00 00                    mov     edx,offset ios near & near dec( ios near & )
 060d  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ios near & (near *)( ))
 0612  8b 53 08                          mov     edx,+8H[ebx]
 0615  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long )
 061a  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 061f  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

  cout << " dirMask:" << n.dirMask << " dirVal: "<<n.dirValues<<endl;
 0624  ba 44 00 00 00                    mov     edx,offset L50
 0629  b8 00 00 00 00                    mov     eax,offset ostream near cout
 062e  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0633  8b 53 0c                          mov     edx,+0cH[ebx]
 0636  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long unsigned )
 063b  ba 3a 00 00 00                    mov     edx,offset L49
 0640  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0645  8b 53 14                          mov     edx,+14H[ebx]
 0648  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long unsigned )
 064d  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 0652  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

  cout << " levelMask:" << n.levelMask << " levelVal: "<<n.levelValues<<endl;
 0657  ba 5a 00 00 00                    mov     edx,offset L52
 065c  b8 00 00 00 00                    mov     eax,offset ostream near cout
 0661  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0666  8b 53 10                          mov     edx,+10H[ebx]
 0669  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long unsigned )
 066e  ba 4e 00 00 00                    mov     edx,offset L51
 0673  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0678  8b 53 18                          mov     edx,+18H[ebx]
 067b  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long unsigned )
 0680  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 0685  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

  cout << " sdSerial:" << n.sdSERIAL << " sdGPIO: "<<n.sdGPIO<<endl<<"}";
  return cout;
 068a  ba 72 00 00 00                    mov     edx,offset L55
 068f  b8 00 00 00 00                    mov     eax,offset ostream near cout
 0694  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0699  8b 53 20                          mov     edx,+20H[ebx]
 069c  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long )
 06a1  ba 68 00 00 00                    mov     edx,offset L54
 06a6  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 06ab  8b 53 1c                          mov     edx,+1cH[ebx]
 06ae  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long )
 06b3  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 06b8  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))
 06bd  ba 66 00 00 00                    mov     edx,offset L53
 06c2  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )

}

/** Default no argument constructor.
 */
 06c7  b8 00 00 00 00                    mov     eax,offset ostream near cout
 06cc  59                                pop     ecx
 06cd  5b                                pop     ebx
 06ce  c3                                ret     

XPort::XPort(){}

/** Initializing constructor. Configures
    XPortConnection member variable.

    @param host XPort host name
    @param gpioIPPort TCP/IP port to use for GPIO
    @param serialIPPort TCP/IP port to use for serial IO
    @param dMask GPIO direction pin-select mask
    @param dValues GPIO initial direction values mask
    @param lMask GPIO level pin-select mask
    @param lValues GPIO initial level (state) values mask
 */
 06cf                    near XPort::XPort():
 06cf  68 04 00 00 00                    push    00000004H
 06d4  e8 00 00 00 00                    call    __CHK
 06d9                    near XPortConnection::XPortConnection():
 06d9  68 04 00 00 00                    push    00000004H
 06de  e8 00 00 00 00                    call    __CHK
 06e3  c3                                ret     

XPort::XPort(char *host, 
	     unsigned int gpioIPPort, 
	     unsigned int serialIPPort,
	     unsigned int dMask,
	     unsigned int dValues,
	     unsigned int lMask,
	     unsigned int lValues){

 06e4                    near XPort::XPort( char near *, int unsigned, int unsigned, int unsigned, int unsigned, int unsigned, int unsigned ):
 06e4  68 20 00 00 00                    push    00000020H
 06e9  e8 00 00 00 00                    call    __CHK
 06ee  56                                push    esi
 06ef  57                                push    edi
 06f0  55                                push    ebp
 06f1  e8 00 00 00 00                    call    near XPortConnection::XPortConnection()
 06f6  89 c6                             mov     esi,eax

  xpConnection.configAll(host,
			 gpioIPPort,serialIPPort,
			 dMask,dValues,
			 lMask,lValues);

 06f8  8b 7c 24 1c                       mov     edi,+1cH[esp]
 06fc  57                                push    edi
 06fd  8b 6c 24 1c                       mov     ebp,+1cH[esp]
 0701  55                                push    ebp
 0702  8b 44 24 1c                       mov     eax,+1cH[esp]
 0706  50                                push    eax
 0707  8b 7c 24 1c                       mov     edi,+1cH[esp]
 070b  57                                push    edi
 070c  89 f0                             mov     eax,esi
 070e  e8 00 00 00 00                    call    int near XPortConnection::configAll( char near *, int unsigned, int unsigned, int unsigned, int unsigned, int unsigned, int unsigned )

}
/** Configures XPortConnection member variable.
    @param host XPort host name
    @param gpioIPPort TCP/IP port to use for GPIO
    @param serialIPPort TCP/IP port to use for serial IO
    @param dMask GPIO direction pin-select mask
    @param dValues GPIO initial direction values mask
    @param lMask GPIO level pin-select mask
    @param lValues GPIO initial level (state) values mask
 */
 0713  89 f0                             mov     eax,esi
 0715  e9 e0 fd ff ff                    jmp     L9

int XPort::configure(char *host, 
		     unsigned int gpioIPPort, 
		     unsigned int serialIPPort,
		     unsigned int dMask,
		     unsigned int dValues,
		     unsigned int lMask,
		     unsigned int lValues){
 071a                    int near XPort::configure( char near *, int unsigned, int unsigned, int unsigned, int unsigned, int unsigned, int unsigned ):
 071a  68 20 00 00 00                    push    00000020H
 071f  e8 00 00 00 00                    call    __CHK
 0724  56                                push    esi
 0725  57                                push    edi
 0726  55                                push    ebp

  xpConnection.configAll(host,
			 gpioIPPort,serialIPPort,
			 dMask,dValues,
			 lMask,lValues);
  return OK;
}
/** @return pointer to XPortConnection member variable */
 0727  8b 74 24 1c                       mov     esi,+1cH[esp]
 072b  56                                push    esi
 072c  8b 7c 24 1c                       mov     edi,+1cH[esp]
 0730  57                                push    edi
 0731  8b 6c 24 1c                       mov     ebp,+1cH[esp]
 0735  55                                push    ebp
 0736  8b 74 24 1c                       mov     esi,+1cH[esp]
 073a  56                                push    esi
 073b  e8 00 00 00 00                    call    int near XPortConnection::configAll( char near *, int unsigned, int unsigned, int unsigned, int unsigned, int unsigned, int unsigned )
 0740  e9 b3 fd ff ff                    jmp     L8

XPortConnection *XPort::getConnection(){
  return &xpConnection;
 0745                    XPortConnection near * near XPort::getConnection():
 0745  68 04 00 00 00                    push    00000004H
 074a  e8 00 00 00 00                    call    __CHK

}

/** Connect to specified XPort TCP/IP socket. 
    @param host XPort TCP/IP host name or address
    @param port TCP/IP port to connect to
    @return Socket file handle
*/
 074f  c3                                ret     

int XPort::connectSocket(char *host, int port){
  int rc,sd;
 0750                    int near XPort::connectSocket( char near *, int ):
 0750  68 40 00 00 00                    push    00000040H
 0755  e8 00 00 00 00                    call    __CHK
 075a  51                                push    ecx
 075b  56                                push    esi
 075c  57                                push    edi
 075d  83 ec 24                          sub     esp,00000024H
 0760  89 df                             mov     edi,ebx

  int opt=1;
  struct sockaddr_in localAddr, servAddr;
  struct hostent *h;

 0762  c7 44 24 20 01 00 
       00 00                             mov     dword ptr +20H[esp],00000001H

  h = gethostbyname(host);
 076a  89 d0                             mov     eax,edx
 076c  e8 00 00 00 00                    call    gethostbyname_
 0771  89 c6                             mov     esi,eax

  if(h==NULL) {
 0773  85 c0                             test    eax,eax
 0775  75 17                             jne     L10

    printf("connectSocket: unknown host '%s' (%d)\n",host,h_errno);
    return ERROR;
  }

 0777  8b 0d 00 00 00 00                 mov     ecx,_h_errno
 077d  51                                push    ecx
 077e  52                                push    edx
 077f  68 7d 00 00 00                    push    offset L56
 0784  e8 00 00 00 00                    call    printf_
 0789  83 c4 0c                          add     esp,0000000cH
 078c  eb 48                             jmp     L12

  servAddr.sin_family = h->h_addrtype;
 078e  8a 40 08          L10             mov     al,+8H[eax]
 0791  88 44 24 11                       mov     +11H[esp],al

  memcpy((char *) &servAddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length);
 0795  8b 5e 0c                          mov     ebx,+0cH[esi]
 0798  8b 56 10                          mov     edx,+10H[esi]
 079b  8b 12                             mov     edx,[edx]
 079d  8d 44 24 14                       lea     eax,+14H[esp]
 07a1  e8 00 00 00 00                    call    memcpy_

  servAddr.sin_port = htons(port);
  
  /* create socket */
 07a6  31 c0                             xor     eax,eax
 07a8  66 89 f8                          mov     ax,di
 07ab  e8 00 00 00 00                    call    htons_
 07b0  66 89 44 24 12                    mov     +12H[esp],ax

  sd = socket(AF_INET, SOCK_STREAM, 0);
 07b5  31 db                             xor     ebx,ebx
 07b7  ba 01 00 00 00                    mov     edx,00000001H
 07bc  b8 02 00 00 00                    mov     eax,00000002H
 07c1  e8 00 00 00 00                    call    socket_
 07c6  89 c6                             mov     esi,eax

  if(sd<0) {
 07c8  85 c0                             test    eax,eax
 07ca  7d 14                             jge     L13

    perror("connectSocket: cannot open socket ");
    return ERROR;
  }

  /* bind any port number */
 07cc  b8 a4 00 00 00                    mov     eax,offset L57
 07d1  e8 00 00 00 00    L11             call    perror_
 07d6  b8 ff ff ff ff    L12             mov     eax,0ffffffffH
 07db  e9 7a 00 00 00                    jmp     L16

  localAddr.sin_family = AF_INET;
 07e0  c6 44 24 01 02    L13             mov     byte ptr +1H[esp],02H

  localAddr.sin_addr.s_addr = htonl(INADDR_ANY);
 07e5  31 c0                             xor     eax,eax
 07e7  e8 00 00 00 00                    call    htonl_
 07ec  89 44 24 04                       mov     +4H[esp],eax

  localAddr.sin_port = htons(0);

  /* set socket options */
 07f0  31 c0                             xor     eax,eax
 07f2  e8 00 00 00 00                    call    htons_
 07f7  66 89 44 24 02                    mov     +2H[esp],ax

  setsockopt(sd,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(opt));

 07fc  6a 04                             push    00000004H
 07fe  8d 4c 24 24                       lea     ecx,+24H[esp]
 0802  bb 04 00 00 00                    mov     ebx,00000004H
 0807  ba ff ff 00 00                    mov     edx,0000ffffH
 080c  89 f0                             mov     eax,esi
 080e  e8 00 00 00 00                    call    setsockopt_

  rc = bind(sd, (struct sockaddr *) &localAddr, sizeof(localAddr));
 0813  bb 10 00 00 00                    mov     ebx,00000010H
 0818  89 e2                             mov     edx,esp
 081a  89 f0                             mov     eax,esi
 081c  e8 00 00 00 00                    call    bind_

  if(rc<0) {
 0821  85 c0                             test    eax,eax
 0823  7d 15                             jge     L14

    printf("connectSocket: cannot bind port TCP %u\n",port);
 0825  57                                push    edi
 0826  68 c7 00 00 00                    push    offset L58
 082b  e8 00 00 00 00                    call    printf_
 0830  83 c4 08                          add     esp,00000008H

    perror("error ");
    return ERROR;
  }
				
  /* connect to server */
 0833  b8 ef 00 00 00                    mov     eax,offset L59
 0838  eb 97                             jmp     L11

  rc = connect(sd, (struct sockaddr *) &servAddr, sizeof(servAddr));
 083a  bb 10 00 00 00    L14             mov     ebx,00000010H
 083f  8d 54 24 10                       lea     edx,+10H[esp]
 0843  89 f0                             mov     eax,esi
 0845  e8 00 00 00 00                    call    connect_

  if(rc<0) {
 084a  85 c0                             test    eax,eax
 084c  7d 0a                             jge     L15

    perror("connectSocket: cannot connect ");
    return ERROR;
  }
  //printf("connectSocket: got socket host:%s port:%d sd:%d\n",host,port,sd);
 084e  b8 f6 00 00 00                    mov     eax,offset L60
 0853  e9 79 ff ff ff                    jmp     L11

  return sd;
 0858  89 f0             L15             mov     eax,esi

}
/** Establish socket connections to one or more XPort sockets.
    @param select Mnemonic indicating which connection to establish
    @return OK on success, ERROR otherwise
    @see XPort.h
    @see BicamConsts.h
*/
 085a  83 c4 24          L16             add     esp,00000024H
 085d  5f                                pop     edi
 085e  5e                                pop     esi
 085f  59                                pop     ecx
 0860  c3                                ret     

int XPort::connectxp(ConnectionID select){
 0861                    int near XPort::connectxp( ConnectionID ):
 0861  68 08 00 00 00                    push    00000008H
 0866  e8 00 00 00 00                    call    __CHK
 086b  53                                push    ebx

  return connectxp(select,TRUE);
 086c  bb 01 00 00 00                    mov     ebx,00000001H
 0871  e8 00 00 00 00                    call    int near XPort::connectxp( ConnectionID, BOOLEAN )

}

/** Establish socket connections to one or more XPort sockets.
    @param select Mnemonic indicating which connection to establish
    @param doConfig Enable XPort configuration when connecting if TRUE
    @return OK on success, ERROR otherwise
    @see XPort.h
    @see BicamConsts.h
*/
 0876  5b                                pop     ebx
 0877  c3                                ret     

int XPort::connectxp(ConnectionID select,boolean doConfig){
  int test;

 0878                    int near XPort::connectxp( ConnectionID, BOOLEAN ):
 0878  68 24 00 00 00                    push    00000024H
 087d  e8 00 00 00 00                    call    __CHK
 0882  51                                push    ecx
 0883  56                                push    esi
 0884  57                                push    edi
 0885  83 ec 14                          sub     esp,00000014H
 0888  89 c6                             mov     esi,eax
 088a  89 d1                             mov     ecx,edx
 088c  89 df                             mov     edi,ebx

  if(select==XPCON_ALL || select==XPCON_GPIO){
 088e  83 fa 02                          cmp     edx,00000002H
 0891  74 05                             je      L17
 0893  83 fa 01                          cmp     edx,00000001H
 0896  75 3b                             jne     L20

    test=connectSocket(xpConnection.getHost(),xpConnection.getpGPIO());
 0898  89 f0             L17             mov     eax,esi
 089a  e8 00 00 00 00                    call    int unsigned near XPortConnection::getpGPIO()
 089f  89 c3                             mov     ebx,eax
 08a1  89 f0                             mov     eax,esi
 08a3  e8 00 00 00 00                    call    char near * near XPortConnection::getHost()
 08a8  89 c2                             mov     edx,eax
 08aa  89 f0                             mov     eax,esi
 08ac  e8 00 00 00 00                    call    int near XPort::connectSocket( char near *, int )

    if(test==ERROR){
 08b1  83 f8 ff                          cmp     eax,0ffffffffH
 08b4  75 14                             jne     L19

      perror("connectxp: connect GPIO failed");
 08b6  b8 15 01 00 00                    mov     eax,offset L61
 08bb  e8 00 00 00 00    L18             call    perror_

      return ERROR;
    }
 08c0  b8 ff ff ff ff                    mov     eax,0ffffffffH
 08c5  e9 ba 00 00 00                    jmp     L25

    xpConnection.setsdGPIO(test);
  }
 08ca  89 c2             L19             mov     edx,eax
 08cc  89 f0                             mov     eax,esi
 08ce  e8 00 00 00 00                    call    void near XPortConnection::setsdGPIO( int )

  if(select==XPCON_ALL || select==XPCON_SERIAL){
 08d3  83 f9 02          L20             cmp     ecx,00000002H
 08d6  74 04                             je      L21
 08d8  85 c9                             test    ecx,ecx
 08da  75 2e                             jne     L23

    test=connectSocket(xpConnection.getHost(),xpConnection.getpSerial());
 08dc  89 f0             L21             mov     eax,esi
 08de  e8 00 00 00 00                    call    int unsigned near XPortConnection::getpSerial()
 08e3  89 c3                             mov     ebx,eax
 08e5  89 f0                             mov     eax,esi
 08e7  e8 00 00 00 00                    call    char near * near XPortConnection::getHost()
 08ec  89 c2                             mov     edx,eax
 08ee  89 f0                             mov     eax,esi
 08f0  e8 00 00 00 00                    call    int near XPort::connectSocket( char near *, int )

    if(test==ERROR){
 08f5  83 f8 ff                          cmp     eax,0ffffffffH
 08f8  75 07                             jne     L22

      perror("connectxp: connect SERIAL failed");
      return ERROR;
    }
 08fa  b8 34 01 00 00                    mov     eax,offset L62
 08ff  eb ba                             jmp     L18

    xpConnection.setsdSerial(test);    
  }

 0901  89 c2             L22             mov     edx,eax
 0903  89 f0                             mov     eax,esi
 0905  e8 00 00 00 00                    call    void near XPortConnection::setsdSerial( int )

  if(doConfig==TRUE){
 090a  83 ff 01          L23             cmp     edi,00000001H
 090d  75 73                             jne     L24

    XPortResponse xpr;
 090f  8d 44 24 0c                       lea     eax,+0cH[esp]
 0913  e8 00 00 00 00                    call    near XPortResponse::XPortResponse()

    XPortCommand xpc(XP_CMD_SET_DIRECTIONS,getConnection()->getDirMask(),getConnection()->getDirValues());
 0918  89 f0                             mov     eax,esi
 091a  e8 00 00 00 00                    call    XPortConnection near * near XPort::getConnection()
 091f  e8 00 00 00 00                    call    int unsigned near XPortConnection::getDirValues()
 0924  89 c1                             mov     ecx,eax
 0926  89 f0                             mov     eax,esi
 0928  e8 00 00 00 00                    call    XPortConnection near * near XPort::getConnection()
 092d  e8 00 00 00 00                    call    int unsigned near XPortConnection::getDirMask()
 0932  89 c3                             mov     ebx,eax
 0934  ba 19 00 00 00                    mov     edx,00000019H
 0939  89 e0                             mov     eax,esp
 093b  e8 00 00 00 00                    call    near XPortCommand::XPortCommand( char unsigned, int unsigned, int unsigned )

    writeRead(&xpc,&xpr);
    
 0940  8d 5c 24 0c                       lea     ebx,+0cH[esp]
 0944  89 e2                             mov     edx,esp
 0946  89 f0                             mov     eax,esi
 0948  e8 00 00 00 00                    call    int near XPort::writeRead( XPortCommand near *, XPortResponse near * )

    xpc.set(XP_CMD_SET_ACTIVE_LEVELS,getConnection()->getLevelMask(),getConnection()->getLevelValues()); 
 094d  89 f0                             mov     eax,esi
 094f  e8 00 00 00 00                    call    XPortConnection near * near XPort::getConnection()
 0954  e8 00 00 00 00                    call    int unsigned near XPortConnection::getLevelValues()
 0959  89 c1                             mov     ecx,eax
 095b  89 f0                             mov     eax,esi
 095d  e8 00 00 00 00                    call    XPortConnection near * near XPort::getConnection()
 0962  e8 00 00 00 00                    call    int unsigned near XPortConnection::getLevelMask()
 0967  89 c3                             mov     ebx,eax
 0969  ba 1a 00 00 00                    mov     edx,0000001aH
 096e  89 e0                             mov     eax,esp
 0970  e8 00 00 00 00                    call    void near XPortCommand::set( char unsigned, int unsigned, int unsigned )

    writeRead(&xpc,&xpr);
  }
 0975  8d 5c 24 0c                       lea     ebx,+0cH[esp]
 0979  89 e2                             mov     edx,esp
 097b  89 f0                             mov     eax,esi
 097d  e8 00 00 00 00                    call    int near XPort::writeRead( XPortCommand near *, XPortResponse near * )

  return OK;
 0982  31 c0             L24             xor     eax,eax

}

/** Disconnect socket connections to one or more XPort sockets.
    @param select Mnemonic indicating which connection to disconnect
    @return OK on success, ERROR otherwise
    @see XPort.h
    @see BicamConsts.h
*/
 0984  83 c4 14          L25             add     esp,00000014H
 0987  5f                                pop     edi
 0988  5e                                pop     esi
 0989  59                                pop     ecx
 098a  c3                                ret     

int XPort::disconnectxp(ConnectionID select){
 098b                    int near XPort::disconnectxp( ConnectionID ):
 098b  68 14 00 00 00                    push    00000014H
 0990  e8 00 00 00 00                    call    __CHK
 0995  53                                push    ebx
 0996  51                                push    ecx
 0997  56                                push    esi
 0998  57                                push    edi
 0999  89 c3                             mov     ebx,eax
 099b  89 d6                             mov     esi,edx

  int test=ERROR;
 099d  bf ff ff ff ff                    mov     edi,0ffffffffH

  int rtn=OK;

 09a2  31 c9                             xor     ecx,ecx

  if(select==XPCON_ALL || select==XPCON_GPIO){
 09a4  83 fa 02                          cmp     edx,00000002H
 09a7  74 05                             je      L26
 09a9  83 fa 01                          cmp     edx,00000001H
 09ac  75 45                             jne     L28

    test=shutdown(xpConnection.getsdGPIO(),SHUT_RDWR);
 09ae  89 d8             L26             mov     eax,ebx
 09b0  e8 00 00 00 00                    call    int near XPortConnection::getsdGPIO()
 09b5  ba 02 00 00 00                    mov     edx,00000002H
 09ba  e8 00 00 00 00                    call    shutdown_
 09bf  89 c7                             mov     edi,eax

    if(test<0){
 09c1  85 c0                             test    eax,eax
 09c3  7d 0f                             jge     L27

      perror("disconnectxp: GPIO socket shutdown failed\n");
 09c5  b8 55 01 00 00                    mov     eax,offset L63
 09ca  e8 00 00 00 00                    call    perror_

      rtn=ERROR;
    }
 09cf  b9 ff ff ff ff                    mov     ecx,0ffffffffH

    close(xpConnection.getsdGPIO());
 09d4  89 d8             L27             mov     eax,ebx
 09d6  e8 00 00 00 00                    call    int near XPortConnection::getsdGPIO()
 09db  e8 00 00 00 00                    call    close_

    if(test<0){
 09e0  85 ff                             test    edi,edi
 09e2  7d 0f                             jge     L28

      perror("disconnectxp: GPIO socket close failed\n");
 09e4  b8 80 01 00 00                    mov     eax,offset L64
 09e9  e8 00 00 00 00                    call    perror_

      rtn=ERROR;
    }
  }
 09ee  b9 ff ff ff ff                    mov     ecx,0ffffffffH

  if(select==XPCON_ALL || select==XPCON_SERIAL){
 09f3  83 fe 02          L28             cmp     esi,00000002H
 09f6  74 04                             je      L29
 09f8  85 f6                             test    esi,esi
 09fa  75 43                             jne     L31

    shutdown(xpConnection.getsdSerial(),SHUT_RDWR);
 09fc  89 d8             L29             mov     eax,ebx
 09fe  e8 00 00 00 00                    call    int near XPortConnection::getsdSerial()
 0a03  ba 02 00 00 00                    mov     edx,00000002H
 0a08  e8 00 00 00 00                    call    shutdown_

    if(test<0){
 0a0d  85 ff                             test    edi,edi
 0a0f  7d 0f                             jge     L30

      perror("disconnectxp: SERIAL socket shutdown failed\n");
 0a11  b8 a8 01 00 00                    mov     eax,offset L65
 0a16  e8 00 00 00 00                    call    perror_

      rtn=ERROR;
    }
 0a1b  b9 ff ff ff ff                    mov     ecx,0ffffffffH

    close(xpConnection.getsdSerial());
 0a20  89 d8             L30             mov     eax,ebx
 0a22  e8 00 00 00 00                    call    int near XPortConnection::getsdSerial()
 0a27  e8 00 00 00 00                    call    close_

    if(test<0){
 0a2c  85 ff                             test    edi,edi
 0a2e  7d 0f                             jge     L31

      perror("disconnectxp: SERIAL socket close failed\n");
 0a30  b8 d5 01 00 00                    mov     eax,offset L66
 0a35  e8 00 00 00 00                    call    perror_

      rtn=ERROR;
    }
  }
  return rtn;
 0a3a  b9 ff ff ff ff                    mov     ecx,0ffffffffH

}
/** Write bytes to the specified socket descriptor.
    @param sd Socket descriptor
    @param buf pointer to character buffer
    @param len number of bytes to write
    @return Number of bytes written if successful, -1 otherwise
*/
 0a3f  89 c8             L31             mov     eax,ecx
 0a41  5f                                pop     edi
 0a42  5e                                pop     esi
 0a43  59                                pop     ecx
 0a44  5b                                pop     ebx
 0a45  c3                                ret     

int XPort::writeBytes(int sd, char *buf, int len){
  int rc;

 0a46                    int near XPort::writeBytes( int, char near *, int ):
 0a46  68 04 00 00 00                    push    00000004H
 0a4b  e8 00 00 00 00                    call    __CHK
 0a50  89 d0                             mov     eax,edx
 0a52  89 da                             mov     edx,ebx
 0a54  89 cb                             mov     ebx,ecx

    rc = send(sd, buf, len, 0);
    
 0a56  31 c9                             xor     ecx,ecx
 0a58  e8 00 00 00 00                    call    send_

    if(rc<0) {
 0a5d  85 c0                             test    eax,eax
 0a5f  7d 0f                             jge     L32

      perror("sendBytes cannot send data");
 0a61  b8 ff 01 00 00                    mov     eax,offset L67
 0a66  e8 00 00 00 00                    call    perror_

      return -1;
    }
    return rc;
 0a6b  b8 ff ff ff ff                    mov     eax,0ffffffffH

}

/** Resd bytes from the specified socket descriptor into 
    a buffer.
    @param sd Socket descriptor
    @param buf pointer to character buffer
    @param len number of bytes to write
    @return Number of bytes read if successful, ERROR otherwise
*/
 0a70  c3                L32             ret     

int XPort::readBytes(int sd, char *buf, int len){
  int n;

 0a71                    int near XPort::readBytes( int, char near *, int ):
 0a71  68 0c 00 00 00                    push    0000000cH
 0a76  e8 00 00 00 00                    call    __CHK
 0a7b  56                                push    esi
 0a7c  89 d6                             mov     esi,edx
 0a7e  89 da                             mov     edx,ebx
 0a80  89 cb                             mov     ebx,ecx

  n = recv(sd, &buf[0], len, 0);
 0a82  31 c9                             xor     ecx,ecx
 0a84  89 f0                             mov     eax,esi
 0a86  e8 00 00 00 00                    call    recv_

  if (n<0) {
 0a8b  85 c0                             test    eax,eax
 0a8d  7d 11                             jge     L34

    perror("readResponse: cannot receive data ");
 0a8f  b8 1a 02 00 00                    mov     eax,offset L68
 0a94  e8 00 00 00 00                    call    perror_

    return ERROR;
 0a99  b8 ff ff ff ff    L33             mov     eax,0ffffffffH
 0a9e  5e                                pop     esi
 0a9f  c3                                ret     

  } else if (n==0) {
 0aa0  0f 85 7f f5 ff ff L34             jne     L1

    printf("readResponse: connection closed by client\n");
 0aa6  68 3d 02 00 00                    push    offset L69
 0aab  e8 00 00 00 00                    call    printf_
 0ab0  83 c4 04                          add     esp,00000004H

    close(sd);
    return ERROR;
  }

  return n;

}

/** Send XPortCommand to XPort GPIO port.
    @param xpCommand Command to send
    @return number of bytes written, -1 otherwise
 */
 0ab3  89 f0                             mov     eax,esi
 0ab5  e8 00 00 00 00                    call    close_
 0aba  eb dd                             jmp     L33

int XPort::writeCommand( XPortCommand *xpCommand){

  char bytes[XPORT_COMMAND_LEN];
 0abc                    int near XPort::writeCommand( XPortCommand near * ):
 0abc  68 20 00 00 00                    push    00000020H
 0ac1  e8 00 00 00 00                    call    __CHK
 0ac6  53                                push    ebx
 0ac7  51                                push    ecx
 0ac8  56                                push    esi
 0ac9  57                                push    edi
 0aca  83 ec 0c                          sub     esp,0000000cH
 0acd  89 c6                             mov     esi,eax
 0acf  89 d3                             mov     ebx,edx

  int sd=xpConnection.getsdGPIO();

 0ad1  e8 00 00 00 00                    call    int near XPortConnection::getsdGPIO()
 0ad6  89 c7                             mov     edi,eax

  return writeBytes(sd,xpCommand->toBytes(bytes),XPORT_COMMAND_LEN);
 0ad8  89 e2                             mov     edx,esp
 0ada  89 d8                             mov     eax,ebx
 0adc  e8 00 00 00 00                    call    char near * near XPortCommand::toBytes( char near * )
 0ae1  b9 09 00 00 00                    mov     ecx,00000009H
 0ae6  89 c3                             mov     ebx,eax
 0ae8  89 fa                             mov     edx,edi
 0aea  89 f0                             mov     eax,esi
 0aec  e8 00 00 00 00                    call    int near XPort::writeBytes( int, char near *, int )

}

/** Read response to XPortCommand into XPortResponse.
    @param xpResponse pointer to XPResponse to store results in
    @return number of bytes read, ERROR otherwise
 */
 0af1  83 c4 0c                          add     esp,0000000cH
 0af4  5f                                pop     edi
 0af5  5e                                pop     esi
 0af6  59                                pop     ecx
 0af7  5b                                pop     ebx
 0af8  c3                                ret     

int XPort::readResponse( XPortResponse *xpResponse){
  char buf[XPORT_RESPONSE_LEN];
 0af9                    int near XPort::readResponse( XPortResponse near * ):
 0af9  68 1c 00 00 00                    push    0000001cH
 0afe  e8 00 00 00 00                    call    __CHK
 0b03  53                                push    ebx
 0b04  51                                push    ecx
 0b05  56                                push    esi
 0b06  57                                push    edi
 0b07  83 ec 08                          sub     esp,00000008H
 0b0a  89 c6                             mov     esi,eax
 0b0c  89 d7                             mov     edi,edx

  int sd=xpConnection.getsdGPIO();

 0b0e  e8 00 00 00 00                    call    int near XPortConnection::getsdGPIO()

  readBytes(sd,buf,XPORT_RESPONSE_LEN);

 0b13  b9 05 00 00 00                    mov     ecx,00000005H
 0b18  89 e3                             mov     ebx,esp
 0b1a  89 c2                             mov     edx,eax
 0b1c  89 f0                             mov     eax,esi
 0b1e  e8 00 00 00 00                    call    int near XPort::readBytes( int, char near *, int )

  if(xpResponse==NULL){
 0b23  85 ff                             test    edi,edi
 0b25  75 07                             jne     L35

    return ERR_NULL;
  }else{
 0b27  b8 ff ff ff ff                    mov     eax,0ffffffffH
 0b2c  eb 09                             jmp     L36

    return xpResponse->parse(buf);
  }
 0b2e  89 e2             L35             mov     edx,esp
 0b30  89 f8                             mov     eax,edi
 0b32  e8 00 00 00 00                    call    int near XPortResponse::parse( char near * )

}
/** Write XPCommand and get response in single operation.
    @param xpCommand Command to send
    @param xpResponse pointer to XPResponse to store results in
    @return number of bytes read, ERROR otherwise
*/
 0b37  83 c4 08          L36             add     esp,00000008H
 0b3a  5f                                pop     edi
 0b3b  5e                                pop     esi
 0b3c  59                                pop     ecx
 0b3d  5b                                pop     ebx
 0b3e  c3                                ret     

int XPort::writeRead( XPortCommand *xpCommand, XPortResponse *xpResponse){
 0b3f                    int near XPort::writeRead( XPortCommand near *, XPortResponse near * ):
 0b3f  68 08 00 00 00                    push    00000008H
 0b44  e8 00 00 00 00                    call    __CHK
 0b49  51                                push    ecx
 0b4a  89 c1                             mov     ecx,eax

  writeCommand(xpCommand);
 0b4c  e8 00 00 00 00                    call    int near XPort::writeCommand( XPortCommand near * )

  return readResponse(xpResponse);
 0b51  89 da                             mov     edx,ebx
 0b53  89 c8                             mov     eax,ecx
 0b55  e8 00 00 00 00                    call    int near XPort::readResponse( XPortResponse near * )

}
/** Write bytes to XPort serial port.
    @param msg pointer to character buffer
    @param len number of bytes to send
    @param offset offset from start of buffer
    @return number of bytes sent, value <0 otherwise
*/
 0b5a  59                                pop     ecx
 0b5b  c3                                ret     

int XPort::writeSerial(const char *msg, unsigned int len, unsigned int offset){
  int rc;
 0b5c                    int near XPort::writeSerial( char const near *, int unsigned, int unsigned ):
 0b5c  68 04 00 00 00                    push    00000004H
 0b61  e8 00 00 00 00                    call    __CHK

  int sd=xpConnection.getsdSerial();

 0b66  e8 00 00 00 00                    call    int near XPortConnection::getsdSerial()

    rc = send(sd, msg, len, offset);
 0b6b  e8 00 00 00 00                    call    send_
 0b70  89 c2                             mov     edx,eax

    if(rc<0) {
 0b72  85 c0                             test    eax,eax
 0b74  7d 0a                             jge     L37

      perror("cannot send message ");
      //close(sd);
      //exit(1);
    }
    return rc;
 0b76  b8 68 02 00 00                    mov     eax,offset L70
 0b7b  e8 00 00 00 00                    call    perror_

}
/** @return XPConnection host TCP/IP address/name. */
 0b80  89 d0             L37             mov     eax,edx
 0b82  c3                                ret     

char *XPort::getHost(){
 0b83                    char near * near XPort::getHost():
 0b83  68 04 00 00 00                    push    00000004H
 0b88  e8 00 00 00 00                    call    __CHK

  return xpConnection.getHost();
}
/** @return XPConnection GPIO TCP/IP port. */
 0b8d                    char near * near XPortConnection::getHost():
 0b8d  68 04 00 00 00                    push    00000004H
 0b92  e8 00 00 00 00                    call    __CHK
 0b97  8b 00                             mov     eax,[eax]
 0b99  c3                                ret     

unsigned int XPort::getpGPIO(){
 0b9a                    int unsigned near XPort::getpGPIO():
 0b9a  68 04 00 00 00                    push    00000004H
 0b9f  e8 00 00 00 00                    call    __CHK

  return xpConnection.getpGPIO();
}
/** @return XPConnection serial port TCP/IP port. */
 0ba4                    int unsigned near XPortConnection::getpGPIO():
 0ba4  68 04 00 00 00                    push    00000004H
 0ba9  e8 00 00 00 00                    call    __CHK
 0bae  8b 40 04                          mov     eax,+4H[eax]
 0bb1  c3                                ret     

unsigned int XPort::getpSerial(){
 0bb2                    int unsigned near XPort::getpSerial():
 0bb2  68 04 00 00 00                    push    00000004H
 0bb7  e8 00 00 00 00                    call    __CHK

  return xpConnection.getpSerial();
}
/** @return XPConnection GPIO socket descriptor. */
 0bbc                    int unsigned near XPortConnection::getpSerial():
 0bbc  68 04 00 00 00                    push    00000004H
 0bc1  e8 00 00 00 00                    call    __CHK
 0bc6  8b 40 08                          mov     eax,+8H[eax]
 0bc9  c3                                ret     

int XPort::getsdGPIO(){
 0bca                    int near XPort::getsdGPIO():
 0bca  68 04 00 00 00                    push    00000004H
 0bcf  e8 00 00 00 00                    call    __CHK

  return xpConnection.getsdGPIO();
}
/** @return XPConnection serial port socket descriptor. */
 0bd4                    int near XPortConnection::getsdGPIO():
 0bd4  68 04 00 00 00                    push    00000004H
 0bd9  e8 00 00 00 00                    call    __CHK
 0bde  8b 40 1c                          mov     eax,+1cH[eax]
 0be1  c3                                ret     

int XPort::getsdSerial(){
 0be2                    int near XPort::getsdSerial():
 0be2  68 04 00 00 00                    push    00000004H
 0be7  e8 00 00 00 00                    call    __CHK

  return xpConnection.getsdSerial();
 0bec                    int near XPortConnection::getsdSerial():
 0bec  68 04 00 00 00                    push    00000004H
 0bf1  e8 00 00 00 00                    call    __CHK
 0bf6  8b 40 20                          mov     eax,+20H[eax]
 0bf9  c3                                ret     

No disassembly errors

------------------------------------------------------------

Segment: CONST  DWORD USE32  0000027d bytes  
 0000  7d 00                   L38             - }.
 0002  2c 30 78 00             L39             - ,0x.
 0006  2c 30 78 00             L40             - ,0x.
 000a  7b 30 78 00             L41             - {0x.
 000e  7d 00                   L42             - }.
 0010  2c 30 78 00             L43             - ,0x.
 0014  7b 00                   L44             - {.
 0016  20 68 6f 73 74 3a 00    L45             -  host:.
 001d  7b 00                   L46             - {.
 001f  20 73 65 72 69 61 6c 50 L47             -  serialP
 0027  6f 72 74 3a 20 00                       - ort: .
 002d  20 67 70 69 6f 50 6f 72 L48             -  gpioPor
 0035  74 3a 30 78 00                          - t:0x.
 003a  20 64 69 72 56 61 6c 3a L49             -  dirVal:
 0042  20 00                                   -  .
 0044  20 64 69 72 4d 61 73 6b L50             -  dirMask
 004c  3a 00                                   - :.
 004e  20 6c 65 76 65 6c 56 61 L51             -  levelVa
 0056  6c 3a 20 00                             - l: .
 005a  20 6c 65 76 65 6c 4d 61 L52             -  levelMa
 0062  73 6b 3a 00                             - sk:.
 0066  7d 00                   L53             - }.
 0068  20 73 64 47 50 49 4f 3a L54             -  sdGPIO:
 0070  20 00                                   -  .
 0072  20 73 64 53 65 72 69 61 L55             -  sdSeria
 007a  6c 3a 00                                - l:.
 007d  63 6f 6e 6e 65 63 74 53 L56             - connectS
 0085  6f 63 6b 65 74 3a 20 75                 - ocket: u
 008d  6e 6b 6e 6f 77 6e 20 68                 - nknown h
 0095  6f 73 74 20 27 25 73 27                 - ost '%s'
 009d  20 28 25 64 29 0a 00                    -  (%d)..
 00a4  63 6f 6e 6e 65 63 74 53 L57             - connectS
 00ac  6f 63 6b 65 74 3a 20 63                 - ocket: c
 00b4  61 6e 6e 6f 74 20 6f 70                 - annot op
 00bc  65 6e 20 73 6f 63 6b 65                 - en socke
 00c4  74 20 00                                - t .
 00c7  63 6f 6e 6e 65 63 74 53 L58             - connectS
 00cf  6f 63 6b 65 74 3a 20 63                 - ocket: c
 00d7  61 6e 6e 6f 74 20 62 69                 - annot bi
 00df  6e 64 20 70 6f 72 74 20                 - nd port 
 00e7  54 43 50 20 25 75 0a 00                 - TCP %u..
 00ef  65 72 72 6f 72 20 00    L59             - error .
 00f6  63 6f 6e 6e 65 63 74 53 L60             - connectS
 00fe  6f 63 6b 65 74 3a 20 63                 - ocket: c
 0106  61 6e 6e 6f 74 20 63 6f                 - annot co
 010e  6e 6e 65 63 74 20 00                    - nnect .
 0115  63 6f 6e 6e 65 63 74 78 L61             - connectx
 011d  70 3a 20 63 6f 6e 6e 65                 - p: conne
 0125  63 74 20 47 50 49 4f 20                 - ct GPIO 
 012d  66 61 69 6c 65 64 00                    - failed.
 0134  63 6f 6e 6e 65 63 74 78 L62             - connectx
 013c  70 3a 20 63 6f 6e 6e 65                 - p: conne
 0144  63 74 20 53 45 52 49 41                 - ct SERIA
 014c  4c 20 66 61 69 6c 65 64                 - L failed
 0154  00                                      - .
 0155  64 69 73 63 6f 6e 6e 65 L63             - disconne
 015d  63 74 78 70 3a 20 47 50                 - ctxp: GP
 0165  49 4f 20 73 6f 63 6b 65                 - IO socke
 016d  74 20 73 68 75 74 64 6f                 - t shutdo
 0175  77 6e 20 66 61 69 6c 65                 - wn faile
 017d  64 0a 00                                - d..
 0180  64 69 73 63 6f 6e 6e 65 L64             - disconne
 0188  63 74 78 70 3a 20 47 50                 - ctxp: GP
 0190  49 4f 20 73 6f 63 6b 65                 - IO socke
 0198  74 20 63 6c 6f 73 65 20                 - t close 
 01a0  66 61 69 6c 65 64 0a 00                 - failed..
 01a8  64 69 73 63 6f 6e 6e 65 L65             - disconne
 01b0  63 74 78 70 3a 20 53 45                 - ctxp: SE
 01b8  52 49 41 4c 20 73 6f 63                 - RIAL soc
 01c0  6b 65 74 20 73 68 75 74                 - ket shut
 01c8  64 6f 77 6e 20 66 61 69                 - down fai
 01d0  6c 65 64 0a 00                          - led..
 01d5  64 69 73 63 6f 6e 6e 65 L66             - disconne
 01dd  63 74 78 70 3a 20 53 45                 - ctxp: SE
 01e5  52 49 41 4c 20 73 6f 63                 - RIAL soc
 01ed  6b 65 74 20 63 6c 6f 73                 - ket clos
 01f5  65 20 66 61 69 6c 65 64                 - e failed
 01fd  0a 00                                   - ..
 01ff  73 65 6e 64 42 79 74 65 L67             - sendByte
 0207  73 20 63 61 6e 6e 6f 74                 - s cannot
 020f  20 73 65 6e 64 20 64 61                 -  send da
 0217  74 61 00                                - ta.
 021a  72 65 61 64 52 65 73 70 L68             - readResp
 0222  6f 6e 73 65 3a 20 63 61                 - onse: ca
 022a  6e 6e 6f 74 20 72 65 63                 - nnot rec
 0232  65 69 76 65 20 64 61 74                 - eive dat
 023a  61 20 00                                - a .
 023d  72 65 61 64 52 65 73 70 L69             - readResp
 0245  6f 6e 73 65 3a 20 63 6f                 - onse: co
 024d  6e 6e 65 63 74 69 6f 6e                 - nnection
 0255  20 63 6c 6f 73 65 64 20                 -  closed 
 025d  62 79 20 63 6c 69 65 6e                 - by clien
 0265  74 0a 00                                - t..
 0268  63 61 6e 6e 6f 74 20 73 L70             - cannot s
 0270  65 6e 64 20 6d 65 73 73                 - end mess
 0278  61 67 65 20 00                          - age .

No disassembly errors

------------------------------------------------------------

Comdat: istream near & near operator >>( istream near &, <long near >::smanip const near & )  SEGMENT ANY '_TEXT'  00000021 bytes  

}


/*
int main(){
  char buf[XPORT_COMMAND_LEN];

  cout << "so far so good\n" << endl;
  cout << ">>> test XPortCommand" << endl;
  cout << "setCommand 0x77 0x4 0x5 "<<endl;
  XPortCommand xpc;
  xpc.set(0x77,0x4,0x5);
  cout << hex << "0x" << (int)xpc.getCommand() << " " << xpc.getP1() << " " << xpc.getP2() << endl;
  cout << "is valid (should be NO) " << (xpc.validate()==IS_VALID?"YES":"NO") << endl;
  xpc.set(GET_DIRECTIONS,0x4,0x7);
  cout << "is valid (should be YES) " << (xpc.validate()==IS_VALID?"YES":"NO") << endl;
  
  unsigned char foo=SET_ACTIVE_LEVELS;
  unsigned int bar=0x8DEF,baz=0xBEAF;
  memcpy(&buf[0],&foo, XP_CMD_LEN);
  memcpy(&buf[1],&bar, XP_PARAM_LEN);
  memcpy(&buf[5],&baz, XP_PARAM_LEN);
  xpc.parse(buf);
  cout << "parse command 0x1a 0x8def 0xbeaf and do showCommand" << endl;
  cout << hex << "0x" << (int)xpc.getCommand() << " 0x" << xpc.getP1() << " 0x" << xpc.getP2() << endl;
  xpc.show();

  cout << ">>> test XPortResponse" << endl;
  cout << "setCommand 0x77 0x4 0x5 "<<endl;
 XPortResponse xpr;
  xpr.set(0x77,0x4);
  cout << hex << "0x" << (int)xpr.getCommand() << " " << xpr.getP1() << endl;
  cout << "is valid (should be NO) " << (xpr.validate()==IS_VALID?"YES":"NO") << endl;
  xpr.set(GET_DIRECTIONS,0x4);
  cout << "is valid (should be YES) " << (xpr.validate()==IS_VALID?"YES":"NO") << endl;

  XPort xport;
  (xport.getConnection())->setTCPIP("c80815e",GPIO_IP_PORT,SERIAL_IP_PORT1);
  (xport.getConnection())->setGPIO(CFG_GPIO_ALL,CFG_GPIO_OUT,CFG_GPIO_ALL,CFG_GPIO_HI);
  xport.connectxp(XPCON_ALL);
  cout << *(xport.getConnection()) <<endl;

  xpc.set(SET_DIRECTIONS,CFG_GPIO_ALL,CFG_GPIO_HI);
  xport.writeCommand(&xpc);
  xport.readResponse(&xpr);

  xpc.set(SET_ACTIVE_LEVELS,CFG_GPIO_ALL,CFG_GPIO_HI);
  xport.writeCommand(&xpc);
  xport.readResponse(&xpr);


  xpc.set(SET_CURRENT_STATES,CFG_GPIO_ALL,CFG_GPIO_HI);
  xport.writeRead(&xpc,&xpr);
  cout<<"cmd:"<<xpc<<endl;
  cout<<"res:"<<xpr<<endl;

  sleep(1);

  xpc.set(SET_CURRENT_STATES,CFG_GPIO_ALL,CFG_GPIO_LO);
  xport.writeRead(&xpc,&xpr);
  cout<<"cmd:"<<xpc<<endl;
  cout<<"res:"<<xpr<<endl;

  xport.writeSerial("This is a test message\r\n");

  xport.disconnectxp(XPCON_ALL);
  return 0;
}
*/
 0000  68 0c 00 00 00                    push    0000000cH
 0005  e8 00 00 00 00                    call    __CHK
 000a  53                                push    ebx
 000b  51                                push    ecx
 000c  89 c3                             mov     ebx,eax
 000e  89 d1                             mov     ecx,edx
 0010  8b 52 04                          mov     edx,+4H[edx]
 0013  8b 00                             mov     eax,[eax]
 0015  8b 40 04                          mov     eax,+4H[eax]
 0018  01 d8                             add     eax,ebx
 001a  ff 11                             call    dword ptr [ecx]
 001c  89 d8                             mov     eax,ebx
 001e  59                                pop     ecx
 001f  5b                                pop     ebx
 0020  c3                                ret     

No disassembly errors

------------------------------------------------------------

Comdat: istream near & near operator >>( istream near &, <int near >::smanip const near & )  SEGMENT ANY '_TEXT'  00000021 bytes  
 0000  68 0c 00 00 00                    push    0000000cH
 0005  e8 00 00 00 00                    call    __CHK
 000a  53                                push    ebx
 000b  51                                push    ecx
 000c  89 c3                             mov     ebx,eax
 000e  89 d1                             mov     ecx,edx
 0010  8b 52 04                          mov     edx,+4H[edx]
 0013  8b 00                             mov     eax,[eax]
 0015  8b 40 04                          mov     eax,+4H[eax]
 0018  01 d8                             add     eax,ebx
 001a  ff 11                             call    dword ptr [ecx]
 001c  89 d8                             mov     eax,ebx
 001e  59                                pop     ecx
 001f  5b                                pop     ebx
 0020  c3                                ret     

No disassembly errors

------------------------------------------------------------

Comdat: ostream near & near operator <<( ostream near &, <long near >::smanip const near & )  SEGMENT ANY '_TEXT'  00000021 bytes  
 0000  68 0c 00 00 00                    push    0000000cH
 0005  e8 00 00 00 00                    call    __CHK
 000a  53                                push    ebx
 000b  51                                push    ecx
 000c  89 c3                             mov     ebx,eax
 000e  89 d1                             mov     ecx,edx
 0010  8b 52 04                          mov     edx,+4H[edx]
 0013  8b 00                             mov     eax,[eax]
 0015  8b 40 04                          mov     eax,+4H[eax]
 0018  01 d8                             add     eax,ebx
 001a  ff 11                             call    dword ptr [ecx]
 001c  89 d8                             mov     eax,ebx
 001e  59                                pop     ecx
 001f  5b                                pop     ebx
 0020  c3                                ret     

No disassembly errors

------------------------------------------------------------

Comdat: ostream near & near operator <<( ostream near &, <int near >::smanip const near & )  SEGMENT ANY '_TEXT'  00000021 bytes  
 0000  68 0c 00 00 00                    push    0000000cH
 0005  e8 00 00 00 00                    call    __CHK
 000a  53                                push    ebx
 000b  51                                push    ecx
 000c  89 c3                             mov     ebx,eax
 000e  89 d1                             mov     ecx,edx
 0010  8b 52 04                          mov     edx,+4H[edx]
 0013  8b 00                             mov     eax,[eax]
 0015  8b 40 04                          mov     eax,+4H[eax]
 0018  01 d8                             add     eax,ebx
 001a  ff 11                             call    dword ptr [ecx]
 001c  89 d8                             mov     eax,ebx
 001e  59                                pop     ecx
 001f  5b                                pop     ebx
 0020  c3                                ret     

No disassembly errors

------------------------------------------------------------
