[ECE 453] Updated Usage document

Just clearing up a small issue...see document

Another small note...
Also, our code runs on VC++ 6.0, which has a certain debug library
msvcrtd.dll
that is not present in older versions, or newer versions, for that matter.
I think the new Express 2008 version uses msvcr90d.dll. Computers without
the correct .dll cannot even run the compiled executables.

In short - use VC++ 6.0, for everything to work well.

Ben G
Networking Group
11/20/08

API Usage file


Whew - here we go.

As of right now, we have data passing working, both to and fro. (TMC sending 
commands to PCs, PCs separately
        sending data to TMC). We are still working on image transmission. 
Currently, all PC addresses are set to 
        one same IP address (not the real IP address) and, along with the TMC 
IP address, need to be changed
        when testing the actual PCs and TMC.

BOTH the TMC and each PC will need to run BOTH a Server and a Client process 
concurrently and separately - the 
        server will wait indefinitely for incoming data/commands, and the 
client will be used whenever you want to 
        send data/commands. Each connection will be assigned different sockets. 

To run this in Visual Studio 6.0, just create a new project, (we used Win32 
ConsoleApp that supports MFC
        applications) add getaddrinfo.h and wrapper4.h to the associated header 
files, and then just include 
        wrapper4.h in your own code. 

        TWO IMPORTANT NOTES: 
        1: You have to add ws2_32.lib to your project object library modules, 
in order for all the linking to 
        work. To do this, Click "Project", then "Settings", then "Link", then 
in the space under 
        "Object/Library Modules" type in "ws2_32.lib". 
        
        2: You have to put the actual files wrapper4.h and getaddrinfo.h into 
the local directory, where all the
        .cpp, .h, .dsw, etc files are. Otherwise, VC++ will complain that 
wrapper4.h and getaddrinfo.h don't 
        exist. Once you do this, go to the file browser on the left hand side, 
and click the right-most tab
        (Should be "FileView"), and navigate to the "Header Files" folder. 
Right click, click "Add files to folder",
        and then add the wrapper4.h and getaddrinfo.h files. After doing this, 
the project should be good to go.
        F7 builds everything, in the correct order. 

        You can use our provided stub code, Client.cpp and Server.cpp, or 
simply add our code to your own.
        In Client.cpp and Server.cpp, there are clearly marked comments telling 
you which part of the stub code
        simulates what - ie. the TMC sending commands to the PCs, or the PCs 
sending data to the TMC. Uncomment
        the section that applies to you.



---------------------------------------------------------------------------------------------------------
Here are the functions as they are in the wrapper4.h file right now. As noted 
above, all currently are 
        operable except for sendImageToTMC() and receiveImage(). Just modify 
the IP addresses at the top of 
        the wrapper4.h file for wherever you are testing your code.
---------------------------------------------------------------------------------------------------------

SOCKET prepareToReceive();                                                      
//returns -1 on error, int sockfd on success
        This will be called first by the server (TMC server and PC servers), 
        and will return the assigned socket that the server is "listening"
        on for connections. 

SOCKET cameraConnectToTMC();                                                    
//returns -1 on error, int sockfd on success
        This will be called by the cameras (PCs) client program to connect 
        to the TMC server when they want to send data. It will return the
        assigned socket for the camera (PC) to send over. 

SOCKET TMCConnectToPC(int pc_id);                                               
//returns -1 on error, int sockfd on success
        This will be called by the TMC client program when it wants to 
        connect to individual PCs in order to send them commands. See 
        wrapper4.h #define statements for current ID settings for each 
        PC. It will return the socket to be talked over for that PC.
        NOTE!!!: It is up to you to keep track of which socket is 
        associated with each PC!

int sendDataToTMC(SOCKET ConnectSocket, char *buf, int bufsize);//-1 on error, 
numbytes sent on success
        The cameras (PCs) client program will call this in order to 
        send data to the TMC. The socket argument will be the one
        returned by cameraConnectToTMC(). Buf is the data you are 
        sending, and bufsize is its size. Doh!

int sendCommandToCamera(SOCKET ConnectSocket, char *buf, int bufsize);  //-1 on 
error, 1 on success
        The TMC client program calls this to send commands to the PCs.
        The socket argument will be whichever socket (returned by
        TMCConnectToPC() ) and hence PC you are sending to. Again,
        buf is the data, bufsize is the size.

int receiveData(SOCKET ListenSocket, int recvbuflen, char *recvbuf);    //-1 on 
error, 1 on success receives data by reference
        This is called by both server programs (TMC server and PC 
        servers) to actually grab the sent data. You must specify the 
        socket you're listening on (returned by prepareToReceive() ),
        the length of the buffer you're reading the data into, and the
        actual pointer to memory you want receiveData to write the data
        to. 
        NOTE: In our stub code, we have receiveData operating in a loop,
        so that after it writes to the memory location you specified, 
        you can immediately make a copy or move it elsewhere so that 
        the next iteration of the loop can continue waiting for the next
        sent data. 


int sendImageToTMC(int image_size, char *buf);  //-1 on error, numbytes sent on 
success
        Not working yet

int receiveImage(int *bytes_recvd, char *buf);  //-1 on error, numbytes rcvd on 
success
        Not working yet

void closeConnection(SOCKET sockfd);
        This function closes the socket specified.

Other related posts:

  • » [ECE 453] Updated Usage document - bgarris