Before Running the Code

Jump to: navigation, search
<< Hooking in the Timer
Testing the Library >>



Now that you have a library and an idea of how to build your timer interface, you are probably wondering how to start using the protocols on your platform. You should at this point, try to use the loopback support built into the protocol stack. This will let you know if there is a problem with the RTOS or the Timer interface. There is one call that you MUST make into the protocol stack before you can start using it. That function is called tfStartTreck(). If you call this function (which does not take any parameters), it will initialize all the stack parameters to defaults, if you do not call tfInitTreckOptions() first. If you have not set a tick length value in <trsystem.h> or with tfInitTreckOptions(), you will get a kernel warning. You will get a kernel error, if you compile for the wrong byte order of your machine (big endian versus little endian). The only call that you can make into the protocol stack, prior to calling tfStartTreck(), is tfInitTreckOptions(). All of the functions mentioned here could be found in the Programmer's Reference. As we mentioned above you can use the function tfInitTreckOptions() to change any of the default parameters used for the stack. It is not recommend that you change any parameters at this point, as the stack should work fine with the defaults that are set up.

The following is an example of how easy it is to start using the protocol stack.

#include <trsocket.h>
 
void main(void)
{
/* Define the variables that I need to Startup */
    int             errorCode;
    int             sd;
 
/* Start the protocol stack */
    errorCode=tfStartTreck ();
 
    if (errorCode == TM_ENOERROR)
    {
/* Now do my loopback code */
        sd=socket (PF_INET,SOCK_DGRAM,0);
                        .
                        .
                        .


<< Hooking in the Timer
Testing the Library >>