Vous êtes sur la page 1sur 9

MYCANIC®

COMMAND SERVER
USER MANUAL

PREPARED BY: EEPod LLC


Revision: 1.04
Release Date: March 22, 2013
Filename: Command Server User Manual.doc

www.eepod.com
Table Of Contents
REVISION HISTORY ................................................................................................................................................1

1 INTRODUCTION ................................................................................................................................................2
1.1 INSTALLATION ..................................................................................................................................................2
1.2 SETUP ............................................................................................................................................................... 2
2 COMMAND SERVER SOCKET INTERFACE ............................................................................................... 3
2.1 COMMAND REFERENCE ....................................................................................................................................3
2.1.1 READ ........................................................................................................................................................ 3
2.1.2 PROG ........................................................................................................................................................ 3
2.2 EXAMPLE TEST PROGRAM ................................................................................................................................ 3
3 ACRONYMS ......................................................................................................................................................... 7

EEPod LLC ii
Release Date: Mar. 22, 2013 Command Server User Manual Revision: 1.04

REVISION HISTORY

Revision Release Date Change Descriptions


1.01 Oct. 9, 2012 First draft.
1.02 Oct. 23, 2012 Added network type to read command.
1.03 Oct. 30, 2012 Several updates. New GNU-based client code example.
1.04 Mar. 22, 2013 Updates for CUSW (FCIP) protocol.

Copyright EEPod LLC 2012 1


Release Date: Mar. 22, 2013 Command Server User Manual Revision: 1.04

1 INTRODUCTION
The Command Server is a small client-server Windows PC application that receiveds commands from a user application and sends the
commands to the MyCANIC over the virtual COM port USB connection. A single instance of the Command Server is capable of
communicating with multiple MyCANICs.

1.1 INSTALLATION
The Command Server is a standalone Windows executable and does not require any installation other than copying the program
to the target directory selected by the user.
1.2 SETUP
Setting up the command server for use with a user application involves connecting the MyCANIC(s) via USB with the Windows
Device Manager (under Control Panel) running and noting the virtual COM port of each MyCANIC. These COM port numbers
will need to be used by the user application for communicating with each MyCANIC using the commands listed in the following
sections.

Copyright EEPod LLC 2012 2


Release Date: Mar. 22, 2013 Command Server User Manual Revision: 1.04

2 COMMAND SERVER SOCKET INTERFACE


When the Command Server is running, it creates a stream socket server on the local machine (IP address 127.0.0.1, port 55667). Any
development or test application can open this socket as a client and communicate using simple ASCII commands.
2.1 COMMAND REFERENCE
There are two commands (read and program) to control the MyCANICs. The customer application can use these two commands
to read the amplifier part/serial numbers or to program the amplifier. All commands and responses start with the virtual COM
port number of the MyCANIC that is to be used. All commands and responses must be terminated with a line feed “\n” character,
followed by a string termination “\0” character.

2.1.1 READ
The READ command is used to start the automatic listening process on the tester and get the hardware and software part
numbers along with the serial number. This command will also clear DTCs.
Example: 6 READ FCTP 0x56
This example command will start the automatic listening process (using EQ $56) on the tester and, after the operator has
selected ‘Yes’ to pass the test, it will read the part numbers and serial number of the FCTP amplifier connected to the
MyCANIC on virtual COM port 6 (COM6). The successful response to this command will be “6 READ OK <Hardware Part
Number> <Software Part Number> <Serial Number>”. An unsuccessful response to this command would be “6 READ
FAIL <description>”, where <description> will be an ASCII string to describe the type of failure. The network architecture
types that will be supported are CIP(CMC), CTP, FCTP and CUSW(FCIP). NOTE: Network type “500” is the Fiat 500 CTP
architecture.
2.1.2 PROG
The PROG command is used to program an amplifier with a specific file.
Example: 6 PROG FCTP
This command will program the amplifier connected to the MyCANIC on virtual COM port 6 (COM6) with the file that
matches the hardware part number read from the amp (05091066.BIN in this case) using the FCTP network architecture and
protocol. Note that the file 05091066.BIN must already be present on the SD card of the MyCANIC. The successful
response to this command will be “6 PROG OK <Hardware Part Number> <Software Part Number> <Serial Number>”. An
unsuccessful response to this command would be “6 PROG FAIL <description>”, where <description> will be an ASCII
string to describe the type of failure. The network architecture types that will be supported are CIP(CMC), CTP, FCTP and
CUSW(FCIP).

2.2 EXAMPLE TEST PROGRAM


The following code is an example test program written in GNU/MingW that demonstrates the simplicity of writing test
applications using the socket server and simple ASCII command strings to read or write signal values. The sample application
below has a console mode interface where the user can type in any command and see the response. The source code is provided
below as well.

Copyright EEPod LLC 2012 3


Release Date: Mar. 22, 2013 Command Server User Manual Revision: 1.04

/* $Id: client.c,v 1.2 2012/10/30 18:30:37 kws Exp $


*****************************************************************************
* Filename: client.c
* Description: Client to the CmdServer
*****************************************************************************
*/
#include <winsock.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/*
** Definitions
*/
#define PORT_NUMBER 55667
int main(int argc, char *argv[])
{
struct sockaddr_in addr_server;
SOCKET server_socket = INVALID_SOCKET;
WSADATA wsa_data;
unsigned long wsa_started = FALSE;
unsigned char server_address[256];
unsigned char command[256];
unsigned char response[256];
unsigned long mode;
int status;

/* Check if the user provided an IP address on the command line */


if (argc > 1)
{
strcpy(server_address, argv[1]);
}
else
{
strcpy(server_address, "127.0.0.1");
}
/* Connect to the server socket */

if (wsa_started == FALSE)
{
/* Startup Windows sockets if not already started */
if (WSAStartup(0x202, &wsa_data) == SOCKET_ERROR)

Copyright EEPod LLC 2012 4


Release Date: Mar. 22, 2013 Command Server User Manual Revision: 1.04

{
printf("WSAStartup() failed with error %d\n", WSAGetLastError());
WSACleanup();
return (-1);
}
/* Setup the server address information */
addr_server.sin_family = AF_INET;
addr_server.sin_addr.s_addr = inet_addr(server_address);
addr_server.sin_port = htons(PORT_NUMBER); // Port

/* Create the socket */


server_socket = socket(AF_INET, SOCK_STREAM, 0);
if (server_socket == INVALID_SOCKET)
{
printf("server socket() failed with error %d\n", WSAGetLastError());
WSACleanup();
return (-1);
}
/* Connect to the server */
if (connect(server_socket, (struct sockaddr *)&addr_server, sizeof(addr_server)) ==
SOCKET_ERROR)
{
printf("server connect() failed with error %d\n", WSAGetLastError());
WSACleanup();
server_socket = INVALID_SOCKET;
return(-1);
}
/* Set the socket to non-blocking */
mode = 1;
ioctlsocket(server_socket, FIONBIO, &mode);
}

/* Process commands and get responses */


while (1)
{
if (kbhit())
{
/* Get the command */
fgets(command, sizeof(command), stdin);
if (strlen(command) > 0)
{
/* Get rid of the newline character */
command[strlen(command) - 1] = '\0';

Copyright EEPod LLC 2012 5


Release Date: Mar. 22, 2013 Command Server User Manual Revision: 1.04

/* Exit loop if user entered nothing */


if (strlen(command) == 0)
{
break;
}
/* Send the command to the server */
if ((status = send(server_socket, command, strlen(command) + 1, 0)) < 0)
{
printf("server send() failed with error %d\n", status);
}
}

/* Check for responses and print them */


status = recv(server_socket, response, sizeof(response), 0);
if (status > 0)
{
printf("%s", response);
}
}
/* Close the socket before exiting */
closesocket(server_socket);
return(0);
}

Copyright EEPod LLC 2012 6


Release Date: Mar. 22, 2013 Command Server User Manual Revision: 1.04

3 ACRONYMS
ASCII American Standard Code for Information Interchange
CAN Controller Area Network
IP Internet Protocol
PC Personal Computer

Copyright EEPod LLC 2012 7

Vous aimerez peut-être aussi