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

Segment: _TEXT  DWORD USE32  000008ad bytes  

/** \file XPortSim.cc */
/****************************************************************************/
/* Copyright (c) 2008 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : XPortSim.cc                                                   */
/* Author   : K Headley                                                     */
/* Project  : Benthic Imaging AUV                                           */
/* Created  : 04/01/2008                                                    */
/****************************************************************************/
/* Modification History:                                                    */
/*  $Id: XPortSim.cc,v 1.5 2012/04/06 01:13:06 headley Exp $    */
/*  $Name: FastSim $  */
/****************************************************************************/

#include <stdio.h>
#include <unistd.h> /* close */
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <string.h>
#include <signal.h>
#include <fcntl.h>
#include "XPort.h"
#include "Utils.h"
#include "qnx_port.h"
#include "BicamConsts.h"

/** shutdown if TRUE */
boolean shutdownFlag=FALSE;
/** quiet (not verbose) output */
boolean verbose=FALSE;

/** Signal handler (SIGINT, SIGTERM) for XPortSim process.
    @param sig signal received
*/
void sig_handler(int sig){
  switch(sig){
  case SIGINT:
 0000                    void near sig_handler( int ):
 0000  68 08 00 00 00                    push    00000008H
 0005  e8 00 00 00 00                    call    __CHK
 000a  52                                push    edx
 000b  83 f8 02                          cmp     eax,00000002H
 000e  72 35                             jb      L4
 0010  76 07                             jbe     L1
 0012  83 f8 0f                          cmp     eax,0000000fH
 0015  74 27                             je      L3
 0017  eb 2c                             jmp     L4

    cout<<"got SIGINT"<<endl;
 0019  ba 00 00 00 00    L1              mov     edx,offset L46
 001e  b8 00 00 00 00    L2              mov     eax,offset ostream near cout
 0023  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0028  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 002d  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

    shutdownFlag=TRUE;
 0032  c7 05 00 00 00 00 
       01 00 00 00                       mov     dword ptr BOOLEAN near shutdownFlag,00000001H

    break;
  case SIGTERM:
 003c  5a                                pop     edx
 003d  c3                                ret     

    cout<<"got SIGTERM"<<endl;
    shutdownFlag=TRUE;
    break;
  default:
 003e  ba 0b 00 00 00    L3              mov     edx,offset L47
 0043  eb d9                             jmp     L2

    cout<<"unhandled signal"<<endl;
  }

  return;
 0045  ba 17 00 00 00    L4              mov     edx,offset L48
 004a  b8 00 00 00 00                    mov     eax,offset ostream near cout
 004f  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0054  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 0059  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

}

/** send bytes to specified socket.
    @param sd socket descriptor
    @param buf byte buffer
    @param len number of bytes to send
*/
 005e  5a                                pop     edx
 005f  c3                                ret     

int sendBytes(int sd, char *buf, int len){
  int rc;

 0060                    int near sendBytes( int, char near *, int ):
 0060  68 08 00 00 00                    push    00000008H
 0065  e8 00 00 00 00                    call    __CHK
 006a  51                                push    ecx

    rc = send(sd, buf, len, 0);
    
 006b  31 c9                             xor     ecx,ecx
 006d  e8 00 00 00 00                    call    send_

    if(rc<0) {
 0072  85 c0                             test    eax,eax
 0074  7d 0f                             jge     L5

      perror("sendBytes cannot send data");
 0076  b8 28 00 00 00                    mov     eax,offset L49
 007b  e8 00 00 00 00                    call    perror_

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

}
/** Send XPortResponse to specified socket.
    @param sd socket descriptor
    @param xpResponse pointer to XPortResponse 
 */
 0085  59                L5              pop     ecx
 0086  c3                                ret     

int sendResponse(int sd, XPortResponse *xpResponse){

  char bytes[XPORT_RESPONSE_LEN];
 0087                    int near sendResponse( int, XPortResponse near * ):
 0087  68 14 00 00 00                    push    00000014H
 008c  e8 00 00 00 00                    call    __CHK
 0091  53                                push    ebx
 0092  51                                push    ecx
 0093  83 ec 08                          sub     esp,00000008H
 0096  89 c1                             mov     ecx,eax
 0098  89 d0                             mov     eax,edx

  xpResponse->toBytes(bytes);
 009a  89 e2                             mov     edx,esp
 009c  e8 00 00 00 00                    call    char near * near XPortResponse::toBytes( char near * )

  return sendBytes(sd,bytes,XPORT_RESPONSE_LEN);
 00a1  bb 05 00 00 00                    mov     ebx,00000005H
 00a6  89 e2                             mov     edx,esp
 00a8  89 c8                             mov     eax,ecx
 00aa  e8 00 00 00 00                    call    int near sendBytes( int, char near *, int )

}
/** Send bytes to specified socket.
    @param sd socket descriptor
    @param msg bytes to send.

*/
 00af  83 c4 08                          add     esp,00000008H
 00b2  59                                pop     ecx
 00b3  5b                                pop     ebx
 00b4  c3                                ret     

int sendMessage(int sd, char *msg){
  int rc;
 00b5                    int near sendMessage( int, char near * ):
 00b5  68 10 00 00 00                    push    00000010H
 00ba  e8 00 00 00 00                    call    __CHK
 00bf  53                                push    ebx
 00c0  51                                push    ecx
 00c1  56                                push    esi
 00c2  89 c6                             mov     esi,eax

    rc = send(sd, msg, strlen(msg), 0);
 00c4  89 d0                             mov     eax,edx
 00c6  e8 00 00 00 00                    call    strlen_
 00cb  31 c9                             xor     ecx,ecx
 00cd  89 c3                             mov     ebx,eax
 00cf  89 f0                             mov     eax,esi
 00d1  e8 00 00 00 00                    call    send_
 00d6  89 c2                             mov     edx,eax

    if(rc<0) {
 00d8  85 c0                             test    eax,eax
 00da  7d 1b                             jge     L6

      perror("cannot send message ");
 00dc  b8 43 00 00 00                    mov     eax,offset L50
 00e1  e8 00 00 00 00                    call    perror_

      close(sd);
 00e6  89 f0                             mov     eax,esi
 00e8  e8 00 00 00 00                    call    close_

      exit(1);
    }
    return rc;
 00ed  b8 01 00 00 00                    mov     eax,00000001H
 00f2  e8 00 00 00 00                    call    exit_

}
/** Start XPortSim server 
    @param host hostname 
*/
void startMockXPort(char *host);

/** Process ID of XPortSim server */
pid_t mockXPortPID;
/** Process ID of GPIO TCP/IP process */
pid_t gpioPID;
/** Process ID of Serial IO TCP/IP process */
pid_t serialPID;

/** Establish listener socket 
    @param sd socket descriptor to assign
    @param hostname XPortSim server hostname
    @param port XPortSim server TCP/IP port
    @param servAddr socket address
*/
 00f7  89 d0             L6              mov     eax,edx
 00f9  5e                                pop     esi
 00fa  59                                pop     ecx
 00fb  5b                                pop     ebx
 00fc  c3                                ret     

int getListenerSocket(int *sd, char *hostname, unsigned short port, struct sockaddr_in *servAddr){
  struct hostent *h;

 00fd                    int near getListenerSocket( int near *, char near *, short unsigned, sockaddr_in near * ):
 00fd  68 20 00 00 00                    push    00000020H
 0102  e8 00 00 00 00                    call    __CHK
 0107  56                                push    esi
 0108  57                                push    edi
 0109  55                                push    ebp
 010a  89 c6                             mov     esi,eax
 010c  89 d7                             mov     edi,edx

  printdbg("getListenerSocket: setting up listener on %s port %d (%hu)\n",hostname,port,port);
  /* create socket */
 010e  0f b7 eb                          movzx   ebp,bx
 0111  55                                push    ebp
 0112  55                                push    ebp
 0113  52                                push    edx
 0114  68 58 00 00 00                    push    offset L51
 0119  e8 00 00 00 00                    call    void near printdbg( char near *, ... )
 011e  83 c4 10                          add     esp,00000010H

  *sd = socket(AF_INET, SOCK_STREAM, 0);
 0121  31 db                             xor     ebx,ebx
 0123  ba 01 00 00 00                    mov     edx,00000001H
 0128  b8 02 00 00 00                    mov     eax,00000002H
 012d  e8 00 00 00 00                    call    socket_
 0132  89 06                             mov     [esi],eax

   if(*sd<0) {
 0134  85 c0                             test    eax,eax
 0136  7d 13                             jge     L8

    perror("getListenerSocket: cannot open socket ");
 0138  b8 94 00 00 00                    mov     eax,offset L52
 013d  e8 00 00 00 00                    call    perror_

    return ERROR;
  }
 0142  b8 ff ff ff ff    L7              mov     eax,0ffffffffH
 0147  5d                                pop     ebp
 0148  5f                                pop     edi
 0149  5e                                pop     esi
 014a  c3                                ret     

   printdbg("getListenerSocket: got socket (%d)\n",*sd);

  /* bind server port */
 014b  50                L8              push    eax
 014c  68 bb 00 00 00                    push    offset L53
 0151  e8 00 00 00 00                    call    void near printdbg( char near *, ... )
 0156  83 c4 08                          add     esp,00000008H

   printdbg("getListenerSocket: calling gethostbyname %s\n",hostname);
 0159  57                                push    edi
 015a  68 df 00 00 00                    push    offset L54
 015f  e8 00 00 00 00                    call    void near printdbg( char near *, ... )
 0164  83 c4 08                          add     esp,00000008H

   h = gethostbyname(hostname);
 0167  89 f8                             mov     eax,edi
 0169  e8 00 00 00 00                    call    gethostbyname_

  if(h==NULL) {
 016e  85 c0                             test    eax,eax
 0170  75 17                             jne     L9

    printdbg("getListenerSocket: unknown host '%s' (%d)\n",hostname,h_errno);
    return ERROR;
  }
 0172  8b 35 00 00 00 00                 mov     esi,_h_errno
 0178  56                                push    esi
 0179  57                                push    edi
 017a  68 0c 01 00 00                    push    offset L55
 017f  e8 00 00 00 00                    call    void near printdbg( char near *, ... )
 0184  83 c4 0c                          add     esp,0000000cH
 0187  eb b9                             jmp     L7

   printdbg("getListenerSocket: gethostbyname complete\n");

 0189  68 37 01 00 00    L9              push    offset L56
 018e  e8 00 00 00 00                    call    void near printdbg( char near *, ... )
 0193  83 c4 04                          add     esp,00000004H

  servAddr->sin_family = AF_INET;
  //memcpy((char *) &servAddr->sin_addr.s_addr, h->h_addr_list[0], h->h_length);
  /* not sure why, but it won't bind using the hostname: 
     memcpy((char *) &servAddr->sin_addr.s_addr, h->h_addr_list[0], h->h_length);
     must use INADDR_ANY
  */
 0196  c6 41 01 02                       mov     byte ptr +1H[ecx],02H

  servAddr->sin_addr.s_addr = htonl(INADDR_ANY);
 019a  31 c0                             xor     eax,eax
 019c  e8 00 00 00 00                    call    htonl_
 01a1  89 41 04                          mov     +4H[ecx],eax

  servAddr->sin_port = htons(port);

 01a4  89 e8                             mov     eax,ebp
 01a6  e8 00 00 00 00                    call    htons_
 01ab  66 89 41 02                       mov     +2H[ecx],ax

  errno=0;
 01af  e8 00 00 00 00                    call    __get_errno_ptr_
 01b4  c7 00 00 00 00 00                 mov     dword ptr [eax],00000000H

  if(bind(*sd, (struct sockaddr *) servAddr, sizeof(*servAddr))<0) {
 01ba  8b 06                             mov     eax,[esi]
 01bc  bb 10 00 00 00                    mov     ebx,00000010H
 01c1  89 ca                             mov     edx,ecx
 01c3  e8 00 00 00 00                    call    bind_
 01c8  85 c0                             test    eax,eax
 01ca  7d 1a                             jge     L10

    printdbg("getListenerSocket: cannot bind port (%d)\n",errno);
    return ERROR;
  }

 01cc  e8 00 00 00 00                    call    __get_errno_ptr_
 01d1  8b 08                             mov     ecx,[eax]
 01d3  51                                push    ecx
 01d4  68 62 01 00 00                    push    offset L57
 01d9  e8 00 00 00 00                    call    void near printdbg( char near *, ... )
 01de  83 c4 08                          add     esp,00000008H
 01e1  e9 5c ff ff ff                    jmp     L7

  listen(*sd,2);    

 01e6  8b 06             L10             mov     eax,[esi]
 01e8  ba 02 00 00 00                    mov     edx,00000002H
 01ed  e8 00 00 00 00                    call    listen_

  return *sd;
 01f2  8b 06                             mov     eax,[esi]

}
/** GPIO handler. 
    Receives incoming XPort GPIO traffic and returns appropriate messages.
*/
 01f4  5d                                pop     ebp
 01f5  5f                                pop     edi
 01f6  5e                                pop     esi
 01f7  c3                                ret     

void *gpioListener(){
  int sd, newSd;
  SOCKLEN svrLen;
  struct sockaddr_in svrAddr;
 01f8                    void near * near gpioListener():
 01f8  68 74 01 00 00                    push    00000174H
 01fd  e8 00 00 00 00                    call    __CHK
 0202  53                                push    ebx
 0203  51                                push    ecx
 0204  52                                push    edx
 0205  56                                push    esi
 0206  57                                push    edi
 0207  55                                push    ebp
 0208  81 ec 4c 01 00 00                 sub     esp,0000014cH

  int MSG_BUFFER_SIZE=32;
  char msgBuffer[32];
  int readLen=0;
 020e  bf 20 00 00 00                    mov     edi,00000020H

  XPortCommand xpCommand;
 0213  8d 84 24 30 01 00 
       00                                lea     eax,+130H[esp]
 021a  e8 00 00 00 00                    call    near XPortCommand::XPortCommand()

  XPortResponse xpResponse;
  int test=0,disconnect=0;
  char hostName[256];

 021f  8d 84 24 3c 01 00 
       00                                lea     eax,+13cH[esp]
 0226  e8 00 00 00 00                    call    near XPortResponse::XPortResponse()

  gethostname(hostName,255);

  /* create socket */
 022b  ba ff 00 00 00                    mov     edx,000000ffH
 0230  89 e0                             mov     eax,esp
 0232  e8 00 00 00 00                    call    gethostname_

  sd = getListenerSocket(&sd,hostName,GPIO_IP_PORT,&svrAddr);
 0237  8d 8c 24 20 01 00 
       00                                lea     ecx,+120H[esp]
 023e  bb f0 77 00 00                    mov     ebx,000077f0H
 0243  89 e2                             mov     edx,esp
 0245  8d 84 24 44 01 00 
       00                                lea     eax,+144H[esp]
 024c  e8 00 00 00 00                    call    int near getListenerSocket( int near *, char near *, short unsigned, sockaddr_in near * )
 0251  89 84 24 44 01 00 
       00                                mov     +144H[esp],eax

  if(sd==ERROR){
 0258  83 f8 ff                          cmp     eax,0ffffffffH
 025b  75 11                             jne     L12

    perror("gpioListener: GPIO listener: cannot open socket\n");
 025d  b8 8c 01 00 00                    mov     eax,offset L58
 0262  e8 00 00 00 00    L11             call    perror_

    return NULL;
  }

  while(1) {
 0267  31 c0                             xor     eax,eax
 0269  e9 0a 02 00 00                    jmp     L23

    if(verbose==TRUE)
 026e  83 3d 00 00 00 00 
       01                L12             cmp     dword ptr BOOLEAN near verbose,00000001H
 0275  75 39                             jne     L13

      cout<<"GPIO listener: waiting on port "<<GPIO_IP_PORT<<" sd:"<<sd<<endl;
 0277  ba c2 01 00 00                    mov     edx,offset L60
 027c  b8 00 00 00 00                    mov     eax,offset ostream near cout
 0281  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0286  ba f0 77 00 00                    mov     edx,000077f0H
 028b  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long )
 0290  ba bd 01 00 00                    mov     edx,offset L59
 0295  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 029a  8b 94 24 44 01 00 
       00                                mov     edx,+144H[esp]
 02a1  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long )
 02a6  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 02ab  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

    listen(sd,2);    

 02b0  ba 02 00 00 00    L13             mov     edx,00000002H
 02b5  8b 84 24 44 01 00 
       00                                mov     eax,+144H[esp]
 02bc  e8 00 00 00 00                    call    listen_

    svrLen = sizeof(svrAddr);
 02c1  c7 84 24 48 01 00 
       00 10 00 00 00                    mov     dword ptr +148H[esp],00000010H

    newSd = accept(sd, (struct sockaddr *) &svrAddr, &svrLen);
 02cc  8d 9c 24 48 01 00 
       00                                lea     ebx,+148H[esp]
 02d3  8d 94 24 20 01 00 
       00                                lea     edx,+120H[esp]
 02da  8b 84 24 44 01 00 
       00                                mov     eax,+144H[esp]
 02e1  e8 00 00 00 00                    call    accept_
 02e6  89 c6                             mov     esi,eax

    if(newSd<0) {
 02e8  85 c0                             test    eax,eax
 02ea  7d 0a                             jge     L14

      perror("GPIO listener: cannot accept connection ");
      return NULL;
    }
 02ec  b8 e2 01 00 00                    mov     eax,offset L61
 02f1  e9 6c ff ff ff                    jmp     L11

    if(verbose==TRUE)
 02f6  83 3d 00 00 00 00 
       01                L14             cmp     dword ptr BOOLEAN near verbose,00000001H
 02fd  75 2e                             jne     L15

      cout<<"GPIO listener: got GPIO connection from "<<inet_ntoa(svrAddr.sin_addr)<<endl;

    /* wait for data */
 02ff  8b 84 24 24 01 00 
       00                                mov     eax,+124H[esp]
 0306  e8 00 00 00 00                    call    inet_ntoa_
 030b  89 c3                             mov     ebx,eax
 030d  ba 0b 02 00 00                    mov     edx,offset L62
 0312  b8 00 00 00 00                    mov     eax,offset ostream near cout
 0317  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 031c  89 da                             mov     edx,ebx
 031e  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0323  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 0328  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

    disconnect=0;
 032d  31 ed             L15             xor     ebp,ebp

    while(!disconnect){
      errno=0;
      readLen=recv(newSd, msgBuffer,MSG_BUFFER_SIZE,0);
      if(readLen<0){
	printdbg("GPIO listener: recv returned %d (errno=%d)\n",readLen,errno);
	switch(errno){
	case ENOTCONN:
	  disconnect=1;
	  break;
	default:
	  break;
	}
 032f  e9 f3 00 00 00                    jmp     L22

      }else if(readLen==0){
 0334  75 12             L16             jne     L17

	printdbg("GPIO listener: connection closed by client\n");
	disconnect=1;
 0336  68 60 02 00 00                    push    offset L64
 033b  e8 00 00 00 00                    call    void near printdbg( char near *, ... )
 0340  83 c4 04                          add     esp,00000004H

      }else{
 0343  e9 26 ff ff ff                    jmp     L12

	if(readLen!=XPORT_COMMAND_LEN){
 0348  83 f8 09          L17             cmp     eax,00000009H
 034b  74 10                             je      L18

	  printdbg("GPIO listener: warning - invalid message length (%d!=%d)\n",readLen,XPORT_COMMAND_LEN);
	}
 034d  6a 09                             push    00000009H
 034f  50                                push    eax
 0350  68 8c 02 00 00                    push    offset L65
 0355  e8 00 00 00 00                    call    void near printdbg( char near *, ... )
 035a  83 c4 0c                          add     esp,0000000cH

	test=xpCommand.parse(msgBuffer);
 035d  8d 94 24 00 01 00 
       00                L18             lea     edx,+100H[esp]
 0364  8d 84 24 30 01 00 
       00                                lea     eax,+130H[esp]
 036b  e8 00 00 00 00                    call    int near XPortCommand::parse( char const near * )
 0370  89 c3                             mov     ebx,eax

	if(test!=IS_VALID){
 0372  85 c0                             test    eax,eax
 0374  74 39                             je      L19

	  if(verbose==TRUE)
 0376  83 3d 00 00 00 00 
       01                                cmp     dword ptr BOOLEAN near verbose,00000001H
 037d  0f 85 9c 00 00 00                 jne     L21

	    cout<<"GPIO listener: invalid command returned ["<<test<<"]"<<endl;
	}else{
 0383  ba c8 02 00 00                    mov     edx,offset L67
 0388  b8 00 00 00 00                    mov     eax,offset ostream near cout
 038d  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0392  89 da                             mov     edx,ebx
 0394  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long )
 0399  ba c6 02 00 00                    mov     edx,offset L66
 039e  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 03a3  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 03a8  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))
 03ad  eb 70                             jmp     L21

	  xpResponse.set(xpCommand.getCommand(),xpCommand.getP1());
	  //printdbg("GPIO listener: sending response:\n");
 03af  8d 84 24 30 01 00 
       00                L19             lea     eax,+130H[esp]
 03b6  e8 00 00 00 00                    call    int unsigned near XPortCommand::getP1()
 03bb  89 c3                             mov     ebx,eax
 03bd  8d 84 24 30 01 00 
       00                                lea     eax,+130H[esp]
 03c4  e8 00 00 00 00                    call    char unsigned near XPortCommand::getCommand()
 03c9  31 d2                             xor     edx,edx
 03cb  88 c2                             mov     dl,al
 03cd  8d 84 24 3c 01 00 
       00                                lea     eax,+13cH[esp]
 03d4  e8 00 00 00 00                    call    void near XPortResponse::set( char unsigned, int unsigned )

	  if(verbose==TRUE)
 03d9  83 3d 00 00 00 00 
       01                                cmp     dword ptr BOOLEAN near verbose,00000001H
 03e0  75 2f                             jne     L20

	    cout<<"GPIO listener: command received - ["<<xpCommand<<"]"<<endl;
 03e2  ba f4 02 00 00                    mov     edx,offset L69
 03e7  b8 00 00 00 00                    mov     eax,offset ostream near cout
 03ec  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 03f1  8d 94 24 30 01 00 
       00                                lea     edx,+130H[esp]
 03f8  e8 00 00 00 00                    call    ostream near & near operator <<( ostream near &, XPortCommand const near & )
 03fd  ba f2 02 00 00                    mov     edx,offset L68
 0402  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0407  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 040c  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

	  sendResponse(newSd,&xpResponse);
 0411  8d 94 24 3c 01 00 
       00                L20             lea     edx,+13cH[esp]
 0418  89 f0                             mov     eax,esi
 041a  e8 00 00 00 00                    call    int near sendResponse( int, XPortResponse near * )

	}
      }
    } 
  }

  return NULL;

 041f  85 ed             L21             test    ebp,ebp
 0421  0f 85 47 fe ff ff                 jne     L12
 0427  e8 00 00 00 00    L22             call    __get_errno_ptr_
 042c  c7 00 00 00 00 00                 mov     dword ptr [eax],00000000H
 0432  31 c9                             xor     ecx,ecx
 0434  89 fb                             mov     ebx,edi
 0436  8d 94 24 00 01 00 
       00                                lea     edx,+100H[esp]
 043d  89 f0                             mov     eax,esi
 043f  e8 00 00 00 00                    call    recv_
 0444  89 c2                             mov     edx,eax
 0446  85 c0                             test    eax,eax
 0448  0f 8d e6 fe ff ff                 jge     L16
 044e  e8 00 00 00 00                    call    __get_errno_ptr_
 0453  8b 18                             mov     ebx,[eax]
 0455  53                                push    ebx
 0456  52                                push    edx
 0457  68 34 02 00 00                    push    offset L63
 045c  e8 00 00 00 00                    call    void near printdbg( char near *, ... )
 0461  83 c4 0c                          add     esp,0000000cH
 0464  e8 00 00 00 00                    call    __get_errno_ptr_
 0469  8b 00                             mov     eax,[eax]
 046b  3d 01 01 00 00                    cmp     eax,00000101H
 0470  0f 84 f8 fd ff ff                 je      L12
 0476  eb a7                             jmp     L21

}

/** Serial handler. 
    Receives incoming XPort Serial traffic and returns appropriate messages.
    ToDo: use local serial port for full emulation.
*/
 0478  81 c4 4c 01 00 00 L23             add     esp,0000014cH
 047e  5d                L24             pop     ebp
 047f  5f                                pop     edi
 0480  5e                                pop     esi
 0481  5a                                pop     edx
 0482  59                                pop     ecx
 0483  5b                                pop     ebx
 0484  c3                                ret     

void *serialListener(){
  int sd, newSd=-1;
  SOCKLEN svrLen;
  struct sockaddr_in svrAddr;
 0485                    void near * near serialListener():
 0485  68 40 02 00 00                    push    00000240H
 048a  e8 00 00 00 00                    call    __CHK
 048f  53                                push    ebx
 0490  51                                push    ecx
 0491  52                                push    edx
 0492  56                                push    esi
 0493  57                                push    edi
 0494  55                                push    ebp
 0495  81 ec 18 02 00 00                 sub     esp,00000218H

  int MSG_BUFFER_SIZE=256;
  char msgBuffer[256];
  int readLen=0;
  int disconnect=0;
  char hostName[256];


 049b  be 00 01 00 00                    mov     esi,00000100H

  gethostname(hostName,255);

  /* create socket */
 04a0  ba ff 00 00 00                    mov     edx,000000ffH
 04a5  89 e0                             mov     eax,esp
 04a7  e8 00 00 00 00                    call    gethostname_

  sd = getListenerSocket(&sd,hostName,SERIAL_IP_PORT1,&svrAddr);
 04ac  8d 8c 24 00 02 00 
       00                                lea     ecx,+200H[esp]
 04b3  bb 11 27 00 00                    mov     ebx,00002711H
 04b8  89 e2                             mov     edx,esp
 04ba  8d 84 24 14 02 00 
       00                                lea     eax,+214H[esp]
 04c1  e8 00 00 00 00                    call    int near getListenerSocket( int near *, char near *, short unsigned, sockaddr_in near * )
 04c6  89 84 24 14 02 00 
       00                                mov     +214H[esp],eax

  if(sd==ERROR){
 04cd  83 f8 ff                          cmp     eax,0ffffffffH
 04d0  75 0f                             jne     L26

    perror("SERIAL listener: cannot open socket");
 04d2  b8 18 03 00 00                    mov     eax,offset L70
 04d7  e8 00 00 00 00    L25             call    perror_

    return NULL;
  }

 04dc  e9 8a 01 00 00                    jmp     L36

  while(shutdownFlag==FALSE) {
 04e1  83 3d 00 00 00 00 
       00                L26             cmp     dword ptr BOOLEAN near shutdownFlag,00000000H
 04e8  0f 85 7d 01 00 00                 jne     L36

    if(verbose==TRUE)
 04ee  83 3d 00 00 00 00 
       01                                cmp     dword ptr BOOLEAN near verbose,00000001H
 04f5  75 39                             jne     L27

      cout<<"SERIAL listener: waiting on port "<<SERIAL_IP_PORT1<<" sd:"<<sd<<endl;
 04f7  ba 41 03 00 00                    mov     edx,offset L72
 04fc  b8 00 00 00 00                    mov     eax,offset ostream near cout
 0501  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0506  ba 11 27 00 00                    mov     edx,00002711H
 050b  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long )
 0510  ba 3c 03 00 00                    mov     edx,offset L71
 0515  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 051a  8b 94 24 14 02 00 
       00                                mov     edx,+214H[esp]
 0521  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long )
 0526  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 052b  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

    listen(sd,2);    

 0530  ba 02 00 00 00    L27             mov     edx,00000002H
 0535  8b 84 24 14 02 00 
       00                                mov     eax,+214H[esp]
 053c  e8 00 00 00 00                    call    listen_

    svrLen = sizeof(svrAddr);
 0541  c7 84 24 10 02 00 
       00 10 00 00 00                    mov     dword ptr +210H[esp],00000010H

    newSd = accept(sd, (struct sockaddr *) &svrAddr, &svrLen);
 054c  8d 9c 24 10 02 00 
       00                                lea     ebx,+210H[esp]
 0553  8d 94 24 00 02 00 
       00                                lea     edx,+200H[esp]
 055a  8b 84 24 14 02 00 
       00                                mov     eax,+214H[esp]
 0561  e8 00 00 00 00                    call    accept_
 0566  89 c5                             mov     ebp,eax

    if(newSd<0) {
 0568  85 c0                             test    eax,eax
 056a  7d 0a                             jge     L28

      perror("SERIAL listener: cannot accept connection ");
      return NULL;
    }
    
 056c  b8 63 03 00 00                    mov     eax,offset L73
 0571  e9 61 ff ff ff                    jmp     L25

    if(verbose==TRUE)
 0576  83 3d 00 00 00 00 
       01                L28             cmp     dword ptr BOOLEAN near verbose,00000001H
 057d  75 2e                             jne     L29

      cout<<"SERIAL listener: got SERIAL connection from "<<inet_ntoa(svrAddr.sin_addr)<<endl;

    /* wait for data */
 057f  8b 84 24 04 02 00 
       00                                mov     eax,+204H[esp]
 0586  e8 00 00 00 00                    call    inet_ntoa_
 058b  89 c7                             mov     edi,eax
 058d  ba 8e 03 00 00                    mov     edx,offset L74
 0592  b8 00 00 00 00                    mov     eax,offset ostream near cout
 0597  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 059c  89 fa                             mov     edx,edi
 059e  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 05a3  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 05a8  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

    disconnect=0;
 05ad  31 ff             L29             xor     edi,edi

    while(!disconnect){
      errno=0;
      readLen=recv(newSd, msgBuffer,MSG_BUFFER_SIZE,0);
      if(readLen<0){
 05af  eb 52                             jmp     L34

	printdbg("SERIAL listener: recv returned %d (errno=%d)\n",readLen,errno);
 05b1  e8 00 00 00 00    L30             call    __get_errno_ptr_
 05b6  8b 18                             mov     ebx,[eax]
 05b8  53                                push    ebx
 05b9  52                                push    edx
 05ba  68 bb 03 00 00                    push    offset L75
 05bf  e8 00 00 00 00                    call    void near printdbg( char near *, ... )
 05c4  83 c4 0c                          add     esp,0000000cH

	switch(errno){
	case ENOTCONN:
	  disconnect=1;
	  break;
	default:
	  break;
	}
 05c7  e8 00 00 00 00                    call    __get_errno_ptr_
 05cc  8b 00                             mov     eax,[eax]
 05ce  3d 01 01 00 00                    cmp     eax,00000101H
 05d3  74 11                             je      L32
 05d5  eb 14                             jmp     L33

      }else if(readLen==0){
 05d7  75 4f             L31             jne     L35

	printdbg("SERIAL listener: connection closed by client\n");
	disconnect=1;
      }else{
 05d9  68 e9 03 00 00                    push    offset L76
 05de  e8 00 00 00 00                    call    void near printdbg( char near *, ... )
 05e3  83 c4 04                          add     esp,00000004H
 05e6  bf 01 00 00 00    L32             mov     edi,00000001H
 05eb  89 f3             L33             mov     ebx,esi
 05ed  31 d2                             xor     edx,edx
 05ef  8d 84 24 00 01 00 
       00                                lea     eax,+100H[esp]
 05f6  e8 00 00 00 00                    call    memset_
 05fb  85 ff                             test    edi,edi
 05fd  0f 85 de fe ff ff                 jne     L26
 0603  e8 00 00 00 00    L34             call    __get_errno_ptr_
 0608  c7 00 00 00 00 00                 mov     dword ptr [eax],00000000H
 060e  31 c9                             xor     ecx,ecx
 0610  89 f3                             mov     ebx,esi
 0612  8d 94 24 00 01 00 
       00                                lea     edx,+100H[esp]
 0619  89 e8                             mov     eax,ebp
 061b  e8 00 00 00 00                    call    recv_
 0620  89 c2                             mov     edx,eax
 0622  85 c0                             test    eax,eax
 0624  7c 8b                             jl      L30
 0626  eb af                             jmp     L31

	msgBuffer[MSG_BUFFER_SIZE]='\0';
 0628  30 e4             L35             xor     ah,ah
 062a  88 a4 34 00 01 00 
       00                                mov     +100H[esp+esi],ah

	if(verbose==TRUE)
 0631  83 3d 00 00 00 00 
       01                                cmp     dword ptr BOOLEAN near verbose,00000001H
 0638  75 b1                             jne     L33

	  cout<<"Serial listener received message:["<<msgBuffer<<"]"<<endl;
      }
      memset(&msgBuffer[0],0x00,MSG_BUFFER_SIZE);
    } 
  }
 063a  ba 19 04 00 00                    mov     edx,offset L78
 063f  b8 00 00 00 00                    mov     eax,offset ostream near cout
 0644  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0649  8d 94 24 00 01 00 
       00                                lea     edx,+100H[esp]
 0650  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0655  ba 17 04 00 00                    mov     edx,offset L77
 065a  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 065f  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 0664  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))
 0669  eb 80                             jmp     L33

  return NULL;

 066b  31 c0             L36             xor     eax,eax

}
/** start XPortSim server 
    @param host hostname
*/
 066d  81 c4 18 02 00 00                 add     esp,00000218H
 0673  e9 06 fe ff ff                    jmp     L24

void startMockXPort(const char *host){
  unsigned foo;
  /* fork processes to act as an XPort stand-in
     One listens for GPIO and the other for serial
     connections.
  */
 0678                    void near startMockXPort( char const near * ):
 0678  68 10 00 00 00                    push    00000010H
 067d  e8 00 00 00 00                    call    __CHK
 0682  53                                push    ebx
 0683  51                                push    ecx
 0684  52                                push    edx
 0685  89 c3                             mov     ebx,eax

  gpioPID=fork();

 0687  e8 00 00 00 00                    call    fork_
 068c  a3 00 00 00 00                    mov     int near gpioPID,eax

  if( gpioPID == -1){
 0691  83 f8 ff                          cmp     eax,0ffffffffH
 0694  75 14                             jne     L37

    perror("startMockXPort: gpio fork");
 0696  b8 3c 04 00 00                    mov     eax,offset L79
 069b  e8 00 00 00 00                    call    perror_

    exit(EXIT_FAILURE);
  }
 06a0  b8 01 00 00 00                    mov     eax,00000001H
 06a5  e8 00 00 00 00                    call    exit_

  if( gpioPID == 0){
 06aa  83 3d 00 00 00 00 
       00                L37             cmp     dword ptr int near gpioPID,00000000H
 06b1  75 50                             jne     L39

    if(verbose==TRUE)
 06b3  83 3d 00 00 00 00 
       01                                cmp     dword ptr BOOLEAN near verbose,00000001H
 06ba  75 38                             jne     L38

      cout<<"startMockXPort: gpio PID "<< (long)getpid() <<" on host "<< host <<endl;
 06bc  e8 00 00 00 00                    call    getpid_
 06c1  89 c1                             mov     ecx,eax
 06c3  ba 60 04 00 00                    mov     edx,offset L81
 06c8  b8 00 00 00 00                    mov     eax,offset ostream near cout
 06cd  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 06d2  89 ca                             mov     edx,ecx
 06d4  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long )
 06d9  ba 56 04 00 00                    mov     edx,offset L80
 06de  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 06e3  89 da                             mov     edx,ebx
 06e5  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 06ea  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 06ef  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

    gpioListener();    
 06f4  e8 00 00 00 00    L38             call    void near * near gpioListener()

    _exit(-1);
  }

 06f9  b8 ff ff ff ff                    mov     eax,0ffffffffH
 06fe  e8 00 00 00 00                    call    _exit_

  errno=0;
 0703  e8 00 00 00 00    L39             call    __get_errno_ptr_
 0708  c7 00 00 00 00 00                 mov     dword ptr [eax],00000000H

  foo=sleep(2);

 070e  b8 02 00 00 00                    mov     eax,00000002H
 0713  e8 00 00 00 00                    call    sleep_

  serialPID=fork();

 0718  e8 00 00 00 00                    call    fork_
 071d  a3 00 00 00 00                    mov     int near serialPID,eax

  if( serialPID == -1){
 0722  83 f8 ff                          cmp     eax,0ffffffffH
 0725  75 14                             jne     L40

    perror("startMockXPort: serial fork");
 0727  b8 7a 04 00 00                    mov     eax,offset L82
 072c  e8 00 00 00 00                    call    perror_

    exit(EXIT_FAILURE);
  }
 0731  b8 01 00 00 00                    mov     eax,00000001H
 0736  e8 00 00 00 00                    call    exit_

  if( serialPID == 0){
 073b  83 3d 00 00 00 00 
       00                L40             cmp     dword ptr int near serialPID,00000000H
 0742  75 50                             jne     L42

    if(verbose==TRUE)
 0744  83 3d 00 00 00 00 
       01                                cmp     dword ptr BOOLEAN near verbose,00000001H
 074b  75 38                             jne     L41

      cout<<"startMockXPort: serial PID "<< (long)getpid() <<" on host "<< host <<endl;
 074d  e8 00 00 00 00                    call    getpid_
 0752  89 c1                             mov     ecx,eax
 0754  ba a0 04 00 00                    mov     edx,offset L84
 0759  b8 00 00 00 00                    mov     eax,offset ostream near cout
 075e  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0763  89 ca                             mov     edx,ecx
 0765  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( long )
 076a  ba 96 04 00 00                    mov     edx,offset L83
 076f  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0774  89 da                             mov     edx,ebx
 0776  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 077b  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 0780  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

    serialListener();
 0785  e8 00 00 00 00    L41             call    void near * near serialListener()

    _exit(-1);
  }

  return;  
 078a  b8 ff ff ff ff                    mov     eax,0ffffffffH
 078f  e8 00 00 00 00                    call    _exit_

}


/** XPortSim Entry Point.
    Starts XPortSim server.
    @param argc number of command line arguments
    @param argv command line parameters
    @returns 0 if normal termination, error code otherwise
*/
 0794  5a                L42             pop     edx
 0795  59                                pop     ecx
 0796  5b                                pop     ebx
 0797  c3                                ret     

int main (int argc, char *argv[]) {
  char xportHost[256];

 0798  68 10 01 00 00    main_           push    00000110H
 079d  e8 00 00 00 00                    call    __CHK
 07a2  53                                push    ebx
 07a3  51                                push    ecx
 07a4  81 ec 00 01 00 00                 sub     esp,00000100H
 07aa  89 c1                             mov     ecx,eax
 07ac  89 d3                             mov     ebx,edx

  cout<<"XPort Simulator starting -- type CTRL-C to quit"<<endl<<endl;

 07ae  ba bc 04 00 00                    mov     edx,offset L85
 07b3  b8 00 00 00 00                    mov     eax,offset ostream near cout
 07b8  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 07bd  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 07c2  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))
 07c7  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 07cc  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

  if(argc>1)
 07d1  83 f9 01                          cmp     ecx,00000001H
 07d4  7e 1b                             jle     L43

    if(strcmp(argv[1],"-v")==0)
 07d6  8b 43 04                          mov     eax,+4H[ebx]
 07d9  ba ec 04 00 00                    mov     edx,offset L86
 07de  e8 00 00 00 00                    call    strcmp_
 07e3  85 c0                             test    eax,eax
 07e5  75 0a                             jne     L43

      verbose=TRUE;

 07e7  c7 05 00 00 00 00 
       01 00 00 00                       mov     dword ptr BOOLEAN near verbose,00000001H

  gethostname(xportHost,255);

 07f1  ba ff 00 00 00    L43             mov     edx,000000ffH
 07f6  89 e0                             mov     eax,esp
 07f8  e8 00 00 00 00                    call    gethostname_

  startMockXPort((const char *)xportHost);
 07fd  89 e0                             mov     eax,esp
 07ff  e8 00 00 00 00                    call    void near startMockXPort( char const near * )

  signal(SIGINT, sig_handler);
 0804  ba 00 00 00 00                    mov     edx,offset void near sig_handler( int )
 0809  b8 02 00 00 00                    mov     eax,00000002H
 080e  e8 00 00 00 00                    call    signal_

  signal(SIGTERM,sig_handler);

 0813  ba 00 00 00 00                    mov     edx,offset void near sig_handler( int )
 0818  b8 0f 00 00 00                    mov     eax,0000000fH
 081d  e8 00 00 00 00                    call    signal_

  sleep(1);
 0822  b8 01 00 00 00                    mov     eax,00000001H
 0827  e8 00 00 00 00                    call    sleep_

  if(verbose==TRUE)
 082c  83 3d 00 00 00 00 
       01                                cmp     dword ptr BOOLEAN near verbose,00000001H
 0833  75 19                             jne     L44

    cout<<"waiting for connection..."<<endl;

  // wait for SIGINT
 0835  ba ef 04 00 00                    mov     edx,offset L87
 083a  b8 00 00 00 00                    mov     eax,offset ostream near cout
 083f  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( char const near * )
 0844  ba 00 00 00 00                    mov     edx,offset ostream near & near endl( ostream near & )
 0849  e8 00 00 00 00                    call    ostream near & near ostream::operator <<( ostream near & (near *)( ))

  while(shutdownFlag==FALSE)
 084e  83 3d 00 00 00 00 
       00                L44             cmp     dword ptr BOOLEAN near shutdownFlag,00000000H
 0855  75 0c                             jne     L45

    sleep(30);

 0857  b8 1e 00 00 00                    mov     eax,0000001eH
 085c  e8 00 00 00 00                    call    sleep_
 0861  eb eb                             jmp     L44

  printf("stopping GPIO server\n");
 0863  68 09 05 00 00    L45             push    offset L88
 0868  e8 00 00 00 00                    call    printf_
 086d  83 c4 04                          add     esp,00000004H

  kill(gpioPID,SIGKILL);
 0870  a1 00 00 00 00                    mov     eax,int near gpioPID
 0875  ba 09 00 00 00                    mov     edx,00000009H
 087a  e8 00 00 00 00                    call    kill_

  printf("stopping SERIAL server\n");
 087f  68 1f 05 00 00                    push    offset L89
 0884  e8 00 00 00 00                    call    printf_
 0889  83 c4 04                          add     esp,00000004H

  kill(serialPID,SIGKILL);

 088c  a1 00 00 00 00                    mov     eax,int near serialPID
 0891  ba 09 00 00 00                    mov     edx,00000009H
 0896  e8 00 00 00 00                    call    kill_

  exit(EXIT_SUCCESS);

  return 0;
 089b  31 c0                             xor     eax,eax
 089d  e8 00 00 00 00                    call    exit_

}
/*  XPort xport(xportHost,
	      XP_GPIO_IP_PORT,XP_SERIAL_IP_PORT1,
	      CFG_MASK_GPIO_SEL_ALL,CFG_GPIO_HI,
	      CFG_MASK_GPIO_SEL_ALL,CFG_GPIO_HI);

  // Connect to the XPort 
  // (both serial and gpio sockets)  
  xport.connectxp(XPCON_ALL);*/
 08a2  31 c0                             xor     eax,eax
 08a4  81 c4 00 01 00 00                 add     esp,00000100H
 08aa  59                                pop     ecx
 08ab  5b                                pop     ebx
 08ac  c3                                ret     

No disassembly errors

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

Segment: CONST  DWORD USE32  00000537 bytes  
 0000  67 6f 74 20 53 49 47 49 L46             - got SIGI
 0008  4e 54 00                                - NT.
 000b  67 6f 74 20 53 49 47 54 L47             - got SIGT
 0013  45 52 4d 00                             - ERM.
 0017  75 6e 68 61 6e 64 6c 65 L48             - unhandle
 001f  64 20 73 69 67 6e 61 6c                 - d signal
 0027  00                                      - .
 0028  73 65 6e 64 42 79 74 65 L49             - sendByte
 0030  73 20 63 61 6e 6e 6f 74                 - s cannot
 0038  20 73 65 6e 64 20 64 61                 -  send da
 0040  74 61 00                                - ta.
 0043  63 61 6e 6e 6f 74 20 73 L50             - cannot s
 004b  65 6e 64 20 6d 65 73 73                 - end mess
 0053  61 67 65 20 00                          - age .
 0058  67 65 74 4c 69 73 74 65 L51             - getListe
 0060  6e 65 72 53 6f 63 6b 65                 - nerSocke
 0068  74 3a 20 73 65 74 74 69                 - t: setti
 0070  6e 67 20 75 70 20 6c 69                 - ng up li
 0078  73 74 65 6e 65 72 20 6f                 - stener o
 0080  6e 20 25 73 20 70 6f 72                 - n %s por
 0088  74 20 25 64 20 28 25 68                 - t %d (%h
 0090  75 29 0a 00                             - u)..
 0094  67 65 74 4c 69 73 74 65 L52             - getListe
 009c  6e 65 72 53 6f 63 6b 65                 - nerSocke
 00a4  74 3a 20 63 61 6e 6e 6f                 - t: canno
 00ac  74 20 6f 70 65 6e 20 73                 - t open s
 00b4  6f 63 6b 65 74 20 00                    - ocket .
 00bb  67 65 74 4c 69 73 74 65 L53             - getListe
 00c3  6e 65 72 53 6f 63 6b 65                 - nerSocke
 00cb  74 3a 20 67 6f 74 20 73                 - t: got s
 00d3  6f 63 6b 65 74 20 28 25                 - ocket (%
 00db  64 29 0a 00                             - d)..
 00df  67 65 74 4c 69 73 74 65 L54             - getListe
 00e7  6e 65 72 53 6f 63 6b 65                 - nerSocke
 00ef  74 3a 20 63 61 6c 6c 69                 - t: calli
 00f7  6e 67 20 67 65 74 68 6f                 - ng getho
 00ff  73 74 62 79 6e 61 6d 65                 - stbyname
 0107  20 25 73 0a 00                          -  %s..
 010c  67 65 74 4c 69 73 74 65 L55             - getListe
 0114  6e 65 72 53 6f 63 6b 65                 - nerSocke
 011c  74 3a 20 75 6e 6b 6e 6f                 - t: unkno
 0124  77 6e 20 68 6f 73 74 20                 - wn host 
 012c  27 25 73 27 20 28 25 64                 - '%s' (%d
 0134  29 0a 00                                - )..
 0137  67 65 74 4c 69 73 74 65 L56             - getListe
 013f  6e 65 72 53 6f 63 6b 65                 - nerSocke
 0147  74 3a 20 67 65 74 68 6f                 - t: getho
 014f  73 74 62 79 6e 61 6d 65                 - stbyname
 0157  20 63 6f 6d 70 6c 65 74                 -  complet
 015f  65 0a 00                                - e..
 0162  67 65 74 4c 69 73 74 65 L57             - getListe
 016a  6e 65 72 53 6f 63 6b 65                 - nerSocke
 0172  74 3a 20 63 61 6e 6e 6f                 - t: canno
 017a  74 20 62 69 6e 64 20 70                 - t bind p
 0182  6f 72 74 20 28 25 64 29                 - ort (%d)
 018a  0a 00                                   - ..
 018c  67 70 69 6f 4c 69 73 74 L58             - gpioList
 0194  65 6e 65 72 3a 20 47 50                 - ener: GP
 019c  49 4f 20 6c 69 73 74 65                 - IO liste
 01a4  6e 65 72 3a 20 63 61 6e                 - ner: can
 01ac  6e 6f 74 20 6f 70 65 6e                 - not open
 01b4  20 73 6f 63 6b 65 74 0a                 -  socket.
 01bc  00                                      - .
 01bd  20 73 64 3a 00          L59             -  sd:.
 01c2  47 50 49 4f 20 6c 69 73 L60             - GPIO lis
 01ca  74 65 6e 65 72 3a 20 77                 - tener: w
 01d2  61 69 74 69 6e 67 20 6f                 - aiting o
 01da  6e 20 70 6f 72 74 20 00                 - n port .
 01e2  47 50 49 4f 20 6c 69 73 L61             - GPIO lis
 01ea  74 65 6e 65 72 3a 20 63                 - tener: c
 01f2  61 6e 6e 6f 74 20 61 63                 - annot ac
 01fa  63 65 70 74 20 63 6f 6e                 - cept con
 0202  6e 65 63 74 69 6f 6e 20                 - nection 
 020a  00                                      - .
 020b  47 50 49 4f 20 6c 69 73 L62             - GPIO lis
 0213  74 65 6e 65 72 3a 20 67                 - tener: g
 021b  6f 74 20 47 50 49 4f 20                 - ot GPIO 
 0223  63 6f 6e 6e 65 63 74 69                 - connecti
 022b  6f 6e 20 66 72 6f 6d 20                 - on from 
 0233  00                                      - .
 0234  47 50 49 4f 20 6c 69 73 L63             - GPIO lis
 023c  74 65 6e 65 72 3a 20 72                 - tener: r
 0244  65 63 76 20 72 65 74 75                 - ecv retu
 024c  72 6e 65 64 20 25 64 20                 - rned %d 
 0254  28 65 72 72 6e 6f 3d 25                 - (errno=%
 025c  64 29 0a 00                             - d)..
 0260  47 50 49 4f 20 6c 69 73 L64             - GPIO lis
 0268  74 65 6e 65 72 3a 20 63                 - tener: c
 0270  6f 6e 6e 65 63 74 69 6f                 - onnectio
 0278  6e 20 63 6c 6f 73 65 64                 - n closed
 0280  20 62 79 20 63 6c 69 65                 -  by clie
 0288  6e 74 0a 00                             - nt..
 028c  47 50 49 4f 20 6c 69 73 L65             - GPIO lis
 0294  74 65 6e 65 72 3a 20 77                 - tener: w
 029c  61 72 6e 69 6e 67 20 2d                 - arning -
 02a4  20 69 6e 76 61 6c 69 64                 -  invalid
 02ac  20 6d 65 73 73 61 67 65                 -  message
 02b4  20 6c 65 6e 67 74 68 20                 -  length 
 02bc  28 25 64 21 3d 25 64 29                 - (%d!=%d)
 02c4  0a 00                                   - ..
 02c6  5d 00                   L66             - ].
 02c8  47 50 49 4f 20 6c 69 73 L67             - GPIO lis
 02d0  74 65 6e 65 72 3a 20 69                 - tener: i
 02d8  6e 76 61 6c 69 64 20 63                 - nvalid c
 02e0  6f 6d 6d 61 6e 64 20 72                 - ommand r
 02e8  65 74 75 72 6e 65 64 20                 - eturned 
 02f0  5b 00                                   - [.
 02f2  5d 00                   L68             - ].
 02f4  47 50 49 4f 20 6c 69 73 L69             - GPIO lis
 02fc  74 65 6e 65 72 3a 20 63                 - tener: c
 0304  6f 6d 6d 61 6e 64 20 72                 - ommand r
 030c  65 63 65 69 76 65 64 20                 - eceived 
 0314  2d 20 5b 00                             - - [.
 0318  53 45 52 49 41 4c 20 6c L70             - SERIAL l
 0320  69 73 74 65 6e 65 72 3a                 - istener:
 0328  20 63 61 6e 6e 6f 74 20                 -  cannot 
 0330  6f 70 65 6e 20 73 6f 63                 - open soc
 0338  6b 65 74 00                             - ket.
 033c  20 73 64 3a 00          L71             -  sd:.
 0341  53 45 52 49 41 4c 20 6c L72             - SERIAL l
 0349  69 73 74 65 6e 65 72 3a                 - istener:
 0351  20 77 61 69 74 69 6e 67                 -  waiting
 0359  20 6f 6e 20 70 6f 72 74                 -  on port
 0361  20 00                                   -  .
 0363  53 45 52 49 41 4c 20 6c L73             - SERIAL l
 036b  69 73 74 65 6e 65 72 3a                 - istener:
 0373  20 63 61 6e 6e 6f 74 20                 -  cannot 
 037b  61 63 63 65 70 74 20 63                 - accept c
 0383  6f 6e 6e 65 63 74 69 6f                 - onnectio
 038b  6e 20 00                                - n .
 038e  53 45 52 49 41 4c 20 6c L74             - SERIAL l
 0396  69 73 74 65 6e 65 72 3a                 - istener:
 039e  20 67 6f 74 20 53 45 52                 -  got SER
 03a6  49 41 4c 20 63 6f 6e 6e                 - IAL conn
 03ae  65 63 74 69 6f 6e 20 66                 - ection f
 03b6  72 6f 6d 20 00                          - rom .
 03bb  53 45 52 49 41 4c 20 6c L75             - SERIAL l
 03c3  69 73 74 65 6e 65 72 3a                 - istener:
 03cb  20 72 65 63 76 20 72 65                 -  recv re
 03d3  74 75 72 6e 65 64 20 25                 - turned %
 03db  64 20 28 65 72 72 6e 6f                 - d (errno
 03e3  3d 25 64 29 0a 00                       - =%d)..
 03e9  53 45 52 49 41 4c 20 6c L76             - SERIAL l
 03f1  69 73 74 65 6e 65 72 3a                 - istener:
 03f9  20 63 6f 6e 6e 65 63 74                 -  connect
 0401  69 6f 6e 20 63 6c 6f 73                 - ion clos
 0409  65 64 20 62 79 20 63 6c                 - ed by cl
 0411  69 65 6e 74 0a 00                       - ient..
 0417  5d 00                   L77             - ].
 0419  53 65 72 69 61 6c 20 6c L78             - Serial l
 0421  69 73 74 65 6e 65 72 20                 - istener 
 0429  72 65 63 65 69 76 65 64                 - received
 0431  20 6d 65 73 73 61 67 65                 -  message
 0439  3a 5b 00                                - :[.
 043c  73 74 61 72 74 4d 6f 63 L79             - startMoc
 0444  6b 58 50 6f 72 74 3a 20                 - kXPort: 
 044c  67 70 69 6f 20 66 6f 72                 - gpio for
 0454  6b 00                                   - k.
 0456  20 6f 6e 20 68 6f 73 74 L80             -  on host
 045e  20 00                                   -  .
 0460  73 74 61 72 74 4d 6f 63 L81             - startMoc
 0468  6b 58 50 6f 72 74 3a 20                 - kXPort: 
 0470  67 70 69 6f 20 50 49 44                 - gpio PID
 0478  20 00                                   -  .
 047a  73 74 61 72 74 4d 6f 63 L82             - startMoc
 0482  6b 58 50 6f 72 74 3a 20                 - kXPort: 
 048a  73 65 72 69 61 6c 20 66                 - serial f
 0492  6f 72 6b 00                             - ork.
 0496  20 6f 6e 20 68 6f 73 74 L83             -  on host
 049e  20 00                                   -  .
 04a0  73 74 61 72 74 4d 6f 63 L84             - startMoc
 04a8  6b 58 50 6f 72 74 3a 20                 - kXPort: 
 04b0  73 65 72 69 61 6c 20 50                 - serial P
 04b8  49 44 20 00                             - ID .
 04bc  58 50 6f 72 74 20 53 69 L85             - XPort Si
 04c4  6d 75 6c 61 74 6f 72 20                 - mulator 
 04cc  73 74 61 72 74 69 6e 67                 - starting
 04d4  20 2d 2d 20 74 79 70 65                 -  -- type
 04dc  20 43 54 52 4c 2d 43 20                 -  CTRL-C 
 04e4  74 6f 20 71 75 69 74 00                 - to quit.
 04ec  2d 76 00                L86             - -v.
 04ef  77 61 69 74 69 6e 67 20 L87             - waiting 
 04f7  66 6f 72 20 63 6f 6e 6e                 - for conn
 04ff  65 63 74 69 6f 6e 2e 2e                 - ection..
 0507  2e 00                                   - ..
 0509  73 74 6f 70 70 69 6e 67 L88             - stopping
 0511  20 47 50 49 4f 20 73 65                 -  GPIO se
 0519  72 76 65 72 0a 00                       - rver..
 051f  73 74 6f 70 70 69 6e 67 L89             - stopping
 0527  20 53 45 52 49 41 4c 20                 -  SERIAL 
 052f  73 65 72 76 65 72 0a 00                 - server..

No disassembly errors

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

Segment: _BSS  DWORD USE32  00000014 bytes  

No disassembly errors

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

Comdat: istream near & near operator >>( istream 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: 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

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