liberdm/src/erdm.c File Reference

#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "erdm.h"
#include "erdminternal.h"
#include "erdmlog.h"
#include "erdmServer.h"

Go to the source code of this file.

Functions

int dmMessageInit (char *szDestination)
void dmMessageFramer (char *szMessage, uDmCommand *pDmCmd)
int dmDisplay (eDmCmdPriority prior, eDmQuality qual)
int dmDisplayPartial (eDmCmdPriority prior, eDmQuality qual, int xUp, int yUp, int xDown, int yDown)
int dmDisplayEraseToWhite (eDmCmdPriority prior)
int dmDump (eDmCmdPriority prior)

Variables

static int fInit = 0
static int sockfd = -1
static struct sockaddr_in serverAdr


Function Documentation

int dmDisplay ( eDmCmdPriority  prior,
eDmQuality  qual 
)

Definition at line 107 of file erdm.c.

00108 {
00109     char    szMsg[DM_MAXCHARONLINE];
00110     uDmCommand dmCmd;
00111 
00112     dmCmd.dmCmdDisplay.cmd = dmCcDisplay;
00113     dmCmd.dmCmdDisplay.priority = prior;
00114     dmCmd.dmCmdDisplay.qual = qual;
00115 
00116     dmMessageFramer(szMsg, &dmCmd);
00117 
00118     if (!fInit)
00119     {
00120         dmMessageInit("127.0.0.1");
00121     }
00122 
00123     sendto(sockfd, szMsg, strlen(szMsg), 0, (struct sockaddr *) &serverAdr, sizeof(serverAdr));
00124     return 0;
00125 }

Here is the call graph for this function:

int dmDisplayEraseToWhite ( eDmCmdPriority  prior  ) 

Definition at line 151 of file erdm.c.

00152 {
00153     char    szMsg[DM_MAXCHARONLINE];
00154     uDmCommand dmCmd;
00155 
00156     dmCmd.dmCmdDisplay.cmd = dmCcEraseToWhite;
00157     dmCmd.dmCmdDisplay.priority = prior;
00158 
00159     dmMessageFramer(szMsg, &dmCmd);
00160 
00161     if (!fInit)
00162     {
00163         dmMessageInit("127.0.0.1");
00164     }
00165 
00166     sendto(sockfd, szMsg, strlen(szMsg), 0, (struct sockaddr *) &serverAdr, sizeof(serverAdr));
00167     return 0;
00168 }

Here is the call graph for this function:

int dmDisplayPartial ( eDmCmdPriority  prior,
eDmQuality  qual,
int  xUp,
int  yUp,
int  xDown,
int  yDown 
)

Definition at line 127 of file erdm.c.

00128 {
00129     char    szMsg[DM_MAXCHARONLINE];
00130     uDmCommand dmCmd;
00131 
00132     dmCmd.dmCmdDisplayPartial.cmd = dmCcDisplayPartial;
00133     dmCmd.dmCmdDisplayPartial.priority = prior;
00134     dmCmd.dmCmdDisplayPartial.qual = qual;
00135     dmCmd.dmCmdDisplayPartial.xUp = xUp;
00136     dmCmd.dmCmdDisplayPartial.yUp = yUp;
00137     dmCmd.dmCmdDisplayPartial.xDown = xDown;
00138     dmCmd.dmCmdDisplayPartial.yDown = yDown;
00139 
00140     dmMessageFramer(szMsg, &dmCmd);
00141 
00142     if (!fInit)
00143     {
00144         dmMessageInit("127.0.0.1");
00145     }
00146 
00147     sendto(sockfd, szMsg, strlen(szMsg), 0, (struct sockaddr *) &serverAdr, sizeof(serverAdr));
00148     return 0;
00149 }

Here is the call graph for this function:

int dmDump ( eDmCmdPriority  prior  ) 

Definition at line 170 of file erdm.c.

00171 {
00172     ERDM_ERRORPRINTF("dmDump is not implemented.\n");
00173     return -1;
00174 }

void dmMessageFramer ( char *  szMessage,
uDmCommand pDmCmd 
)

Definition at line 81 of file erdm.c.

00082 {
00083     switch ((int) pDmCmd->dmCmdGeneric.cmd)
00084     {
00085     case (int) dmCcDisplay:
00086         sprintf(szMessage, "!%d,%d,%d", (int) pDmCmd->dmCmdGeneric.cmd, (int) pDmCmd->dmCmdDisplay.priority,
00087                 (int) pDmCmd->dmCmdDisplay.qual);
00088         break;
00089 
00090     case (int) dmCcDisplayPartial:
00091         sprintf(szMessage, "!%d,%d,%d,%d,%d,%d,%d", (int) pDmCmd->dmCmdGeneric.cmd, (int) pDmCmd->dmCmdDisplay.priority,
00092                 (int) pDmCmd->dmCmdDisplay.qual, pDmCmd->dmCmdDisplayPartial.xUp, pDmCmd->dmCmdDisplayPartial.yUp,
00093                 pDmCmd->dmCmdDisplayPartial.xDown, pDmCmd->dmCmdDisplayPartial.yDown);
00094         break;
00095 
00096     case (int) dmCcEraseToWhite:
00097         sprintf(szMessage, "!%d,%d", (int) pDmCmd->dmCmdGeneric.cmd, (int) pDmCmd->dmCmdDisplay.priority);
00098         break;
00099 
00100     default:
00101         strcpy(szMessage, "error");
00102         ERDM_ERRORPRINTF("Command Code %d not supported", (int) pDmCmd->dmCmdGeneric.cmd);
00103         break;
00104     }
00105 }

int dmMessageInit ( char *  szDestination  ) 

Definition at line 44 of file erdm.c.

00045 {
00046     int     port;
00047     int     ret;
00048     struct in_addr destinationAdr;
00049 
00050     // Note:
00051     //   INADDR_LOOPBACK : "127.0.0.1"
00052     //   INADDR_ANY      : "0.0.0.0"
00053 
00054     if ((ret = inet_pton(AF_INET, szDestination, &destinationAdr)) == 1)
00055     {
00056         ERDM_LOGPRINTF("Sending messages to %s.\n", szDestination);
00057     }
00058     else if (ret == 0)
00059     {
00060         ERDM_ERRORPRINTF("%s not a presentation IP address (not in dotted decimal format).\n", szDestination);
00061         return -1;
00062     }
00063     else
00064     {
00065         ERDM_ERRORPRINTF("Failed to convert to a numeric IP address.\n");
00066         return -2;
00067     }
00068 
00069     dmGetServerPort(&port);
00070 
00071     sockfd = socket(AF_INET, SOCK_DGRAM, 0);
00072     bzero(&serverAdr, sizeof(serverAdr));
00073     serverAdr.sin_family = AF_INET;
00074     serverAdr.sin_addr.s_addr = destinationAdr.s_addr;
00075     serverAdr.sin_port = htons(port);
00076 
00077     fInit = 1;
00078     return 0;
00079 }

Here is the call graph for this function:


Variable Documentation

int fInit = 0 [static]

Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.

Definition at line 37 of file erdm.c.

struct sockaddr_in serverAdr [static]

Definition at line 39 of file erdm.c.

int sockfd = -1 [static]

Definition at line 38 of file erdm.c.


Generated on Sun Dec 14 17:11:29 2008 by  doxygen 1.5.6