cmp.c File Reference

#include <stdio.h>
#include "pi-debug.h"
#include "pi-source.h"
#include "pi-socket.h"
#include "pi-padp.h"
#include "pi-cmp.h"
#include "pi-error.h"

Include dependency graph for cmp.c:

Go to the source code of this file.

Functions

static int cmp_flush (pi_socket_t *ps, int flags)
static int cmp_getsockopt (pi_socket_t *ps, int level, int option_name, void *option_value, size_t *option_len)
static int cmp_setsockopt (pi_socket_t *ps, int level, int option_name, const void *option_value, size_t *option_len)
static pi_protocol_tcmp_protocol_dup (pi_protocol_t *prot)
static void cmp_protocol_free (pi_protocol_t *prot)
pi_protocol_tcmp_protocol (void)
int cmp_rx_handshake (pi_socket_t *ps, int establishrate, int establishhighrate)
int cmp_tx_handshake (pi_socket_t *ps)
ssize_t cmp_tx (pi_socket_t *ps, const unsigned char *buf, size_t len, int flags)
ssize_t cmp_rx (pi_socket_t *ps, pi_buffer_t *msg, size_t len, int flags)
int cmp_init (pi_socket_t *ps, int baudrate)
int cmp_abort (pi_socket_t *ps, int reason)
int cmp_wakeup (pi_socket_t *ps, int maxbaud)
void cmp_dump (const unsigned char *cmp, int rxtx)


Function Documentation

int cmp_abort ( pi_socket_t ps,
int  reason 
)

Definition at line 451 of file cmp.c.

References cmp_tx(), pi_protocol::data, pi_cmp_data::flags, LOG, PI_CMP_TYPE_ABRT, PI_DBG_CMP, PI_DBG_LVL_NONE, PI_ERR_SOCK_INVALID, PI_LEVEL_CMP, pi_protocol(), pi_set_error(), pi_socket::sd, and pi_cmp_data::type.

Referenced by cmp_rx_handshake().

00452 {
00453         pi_protocol_t *prot;
00454         struct  pi_cmp_data *data;
00455         
00456         prot = pi_protocol(ps->sd, PI_LEVEL_CMP);
00457         if (prot == NULL)
00458                 return pi_set_error(ps->sd, PI_ERR_SOCK_INVALID);
00459 
00460         data = (struct pi_cmp_data *)prot->data;
00461         data->type = PI_CMP_TYPE_ABRT;
00462         data->flags = reason;
00463 
00464         LOG((PI_DBG_CMP, PI_DBG_LVL_NONE, "CMP ABORT\n"));
00465 
00466         return cmp_tx (ps, NULL, 0, 0);
00467 }

Here is the call graph for this function:

void cmp_dump ( const unsigned char *  cmp,
int  rxtx 
)

Definition at line 620 of file cmp.c.

References get_byte, get_long, LOG, PI_CMP_OFFSET_BAUD, PI_CMP_OFFSET_FLGS, PI_CMP_OFFSET_TYPE, PI_CMP_OFFSET_VERS, PI_CMP_TYPE_ABRT, PI_CMP_TYPE_INIT, PI_CMP_TYPE_WAKE, PI_DBG_CMP, PI_DBG_LVL_NONE, and pi_padp_data::type.

00621 {
00622         char *type;
00623 
00624         (void) rxtx;
00625 
00626         switch (get_byte(&cmp[PI_CMP_OFFSET_TYPE])) {
00627                 case PI_CMP_TYPE_WAKE:
00628                         type = "WAKE";
00629                         break;
00630                 case PI_CMP_TYPE_INIT:
00631                         type = "INIT";
00632                         break;
00633                 case PI_CMP_TYPE_ABRT:
00634                         type = "ABRT";
00635                         break;
00636                 default:
00637                         type = "UNK";
00638                         break;
00639         }
00640         
00641         LOG((PI_DBG_CMP, PI_DBG_LVL_NONE,
00642             "CMP %s %s Type: 0x%02x Flags: 0x%02x Version: 0x%04x Baud: %d\n",
00643                 rxtx ? "TX" : "RX", type,
00644                 get_byte(&cmp[PI_CMP_OFFSET_TYPE]), 
00645                 get_byte(&cmp[PI_CMP_OFFSET_FLGS]),
00646                 get_long(&cmp[PI_CMP_OFFSET_VERS]),
00647                 get_long(&cmp[PI_CMP_OFFSET_BAUD])));
00648 }

static int cmp_flush ( pi_socket_t ps,
int  flags 
) [static]

Definition at line 392 of file cmp.c.

References pi_protocol::flush, PI_ERR_SOCK_INVALID, PI_LEVEL_CMP, pi_protocol(), pi_protocol_next(), pi_set_error(), and pi_socket::sd.

Referenced by cmp_protocol().

00393 {
00394         pi_protocol_t   *prot,
00395                         *next;
00396 
00397         prot = pi_protocol(ps->sd, PI_LEVEL_CMP);
00398         if (prot == NULL)
00399                 return pi_set_error(ps->sd, PI_ERR_SOCK_INVALID);
00400 
00401         next = pi_protocol_next(ps->sd, PI_LEVEL_CMP);
00402         if (next == NULL)
00403                 return pi_set_error(ps->sd, PI_ERR_SOCK_INVALID);
00404 
00405         return next->flush(ps, flags);
00406 }

Here is the call graph for this function:

static int cmp_getsockopt ( pi_socket_t ps,
int  level,
int  option_name,
void *  option_value,
size_t *  option_len 
) [static]

Definition at line 512 of file cmp.c.

References pi_cmp_data::baudrate, pi_protocol::data, pisock::error, pi_cmp_data::flags, PI_CMP_BAUD, PI_CMP_FLAGS, PI_CMP_TYPE, PI_CMP_VERS, PI_ERR_GENERIC_ARGUMENT, PI_ERR_SOCK_INVALID, PI_LEVEL_CMP, pi_protocol(), pi_set_error(), pi_socket::sd, pi_cmp_data::type, and pi_cmp_data::version.

Referenced by cmp_protocol().

00514 {
00515         pi_protocol_t *prot;
00516         struct  pi_cmp_data *data;
00517 
00518         (void) level;
00519 
00520         prot = pi_protocol(ps->sd, PI_LEVEL_CMP);
00521         if (prot == NULL)
00522                 return pi_set_error(ps->sd, PI_ERR_SOCK_INVALID);
00523         data = (struct pi_cmp_data *)prot->data;
00524 
00525         switch (option_name) {
00526                 case PI_CMP_TYPE:
00527                         if (*option_len != sizeof (data->type))
00528                                 goto error;
00529                         memcpy (option_value, &data->type,
00530                                 sizeof (data->type));
00531                         *option_len = sizeof (data->type);
00532                         break;
00533 
00534                 case PI_CMP_FLAGS:
00535                         if (*option_len != sizeof (data->flags))
00536                                 goto error;
00537                         memcpy (option_value, &data->flags,
00538                                 sizeof (data->flags));
00539                         *option_len = sizeof (data->flags);
00540                         break;
00541 
00542                 case PI_CMP_VERS:
00543                         if (*option_len != sizeof (data->version))
00544                                 goto error;
00545                         memcpy (option_value, &data->version,
00546                                 sizeof (data->version));
00547                         *option_len = sizeof (data->version);
00548                         break;
00549 
00550                 case PI_CMP_BAUD:
00551                         if (*option_len != sizeof (data->baudrate))
00552                                 goto error;
00553                         memcpy (option_value, &data->baudrate,
00554                                 sizeof (data->baudrate));
00555                         *option_len = sizeof (data->baudrate);
00556                         break;
00557         }
00558 
00559         return 0;
00560         
00561  error:
00562         errno = EINVAL;
00563         return pi_set_error(ps->sd, PI_ERR_GENERIC_ARGUMENT);
00564 }

Here is the call graph for this function:

int cmp_init ( pi_socket_t ps,
int  baudrate 
)

Definition at line 420 of file cmp.c.

References pi_cmp_data::baudrate, CMP_FL_CHANGE_BAUD_RATE, CMP_FL_LONG_PACKET_SUPPORT, cmp_tx(), pi_protocol::data, pi_cmp_data::flags, PI_CMP_TYPE_INIT, PI_ERR_SOCK_INVALID, PI_LEVEL_CMP, pi_protocol(), pi_set_error(), pi_socket::sd, and pi_cmp_data::type.

Referenced by cmp_rx_handshake().

00421 {
00422         pi_protocol_t *prot;
00423         struct  pi_cmp_data *data;
00424 
00425         prot = pi_protocol(ps->sd, PI_LEVEL_CMP);
00426         if (prot == NULL)
00427                 return pi_set_error(ps->sd, PI_ERR_SOCK_INVALID);
00428         data = (struct pi_cmp_data *)prot->data;
00429 
00430         data->type = PI_CMP_TYPE_INIT;
00431         data->flags = CMP_FL_LONG_PACKET_SUPPORT;
00432         if (baudrate != 9600)
00433                 data->flags = CMP_FL_CHANGE_BAUD_RATE;
00434         data->baudrate = baudrate;
00435 
00436         return cmp_tx(ps, NULL, 0, 0);
00437 }

Here is the call graph for this function:

pi_protocol_t* cmp_protocol ( void   ) 

Definition at line 136 of file cmp.c.

References pi_cmp_data::baudrate, cmp_flush(), cmp_getsockopt(), cmp_protocol_dup(), cmp_protocol_free(), cmp_rx(), cmp_setsockopt(), cmp_tx(), pi_protocol::data, pi_protocol::dup, pi_cmp_data::flags, pi_protocol::flush, pi_protocol::free, pi_protocol::getsockopt, pi_protocol::level, PI_LEVEL_CMP, pi_protocol::read, pi_protocol::setsockopt, pi_cmp_data::type, pi_cmp_data::version, and pi_protocol::write.

00137 {
00138         pi_protocol_t *prot;
00139         struct  pi_cmp_data *data;
00140 
00141         prot = (pi_protocol_t *)malloc (sizeof (pi_protocol_t));        
00142         data = (struct pi_cmp_data *)malloc (sizeof (struct pi_cmp_data));
00143 
00144         if (prot != NULL && data != NULL) {
00145                 prot->level             = PI_LEVEL_CMP;
00146                 prot->dup               = cmp_protocol_dup;
00147                 prot->free              = cmp_protocol_free;
00148                 prot->read              = cmp_rx;
00149                 prot->write             = cmp_tx;
00150                 prot->flush             = cmp_flush;
00151                 prot->getsockopt        = cmp_getsockopt;
00152                 prot->setsockopt        = cmp_setsockopt;
00153 
00154                 data->type      = 0;
00155                 data->flags     = 0;
00156                 data->version   = 0;
00157                 data->baudrate  = 0;
00158 
00159                 prot->data      = data;
00160 
00161         } else if (prot != NULL) {
00162                 free(prot);
00163                 prot = NULL;
00164         } else if (data != NULL) {
00165                 free(data);
00166                 data = NULL;
00167         }
00168 
00169         return prot;
00170 }

Here is the call graph for this function:

static pi_protocol_t * cmp_protocol_dup ( pi_protocol_t prot  )  [static]

Definition at line 62 of file cmp.c.

References pi_cmp_data::baudrate, pi_protocol::data, pi_protocol::dup, pi_cmp_data::flags, pi_protocol::flush, pi_protocol::free, pi_protocol::getsockopt, pi_protocol::level, pi_protocol::read, pi_protocol::setsockopt, pi_cmp_data::type, pi_cmp_data::version, and pi_protocol::write.

Referenced by cmp_protocol().

00063 {
00064         pi_protocol_t *new_prot;
00065 
00066         struct  pi_cmp_data      *data,
00067                                  *new_data;
00068         
00069         new_prot = (pi_protocol_t *)malloc (sizeof (pi_protocol_t));
00070         new_data = (struct pi_cmp_data *)malloc (sizeof (struct pi_cmp_data));
00071 
00072         if ( (new_prot != NULL) && (new_data != NULL) ) {
00073                 new_prot->level         = prot->level;
00074                 new_prot->dup           = prot->dup;
00075                 new_prot->free          = prot->free;
00076                 new_prot->read          = prot->read;
00077                 new_prot->write         = prot->write;
00078                 new_prot->flush         = prot->flush;
00079                 new_prot->getsockopt    = prot->getsockopt;
00080                 new_prot->setsockopt    = prot->setsockopt;
00081 
00082                 data = (struct pi_cmp_data *)prot->data;
00083                 new_data->type          = data->type;
00084                 new_data->flags         = data->flags;
00085                 new_data->version       = data->version;
00086                 new_data->baudrate      = data->baudrate;
00087 
00088                 new_prot->data          = new_data;
00089 
00090         } else if (new_prot != NULL) {
00091                 free(new_prot);
00092                 new_prot = NULL;
00093         } else if (new_data != NULL) {
00094                 free(new_data);
00095                 new_data = NULL;
00096         }
00097 
00098         return new_prot;
00099 }

static void cmp_protocol_free ( pi_protocol_t prot  )  [static]

Definition at line 114 of file cmp.c.

References pi_protocol::data.

Referenced by cmp_protocol().

00115 {
00116         if (prot != NULL) {
00117                 if (prot->data != NULL)
00118                         free(prot->data);
00119                 free(prot);
00120         }
00121 }

ssize_t cmp_rx ( pi_socket_t ps,
pi_buffer_t msg,
size_t  len,
int  flags 
)

Definition at line 347 of file cmp.c.

References pi_cmp_data::baudrate, CHECK, cmp_dump(), pi_buffer_t::data, pi_protocol::data, pi_cmp_data::flags, get_byte, get_long, get_short, LOG, PI_CMP_OFFSET_BAUD, PI_CMP_OFFSET_FLGS, PI_CMP_OFFSET_TYPE, PI_CMP_OFFSET_VERS, PI_DBG_CMP, PI_DBG_LVL_DEBUG, PI_DBG_LVL_INFO, PI_ERR_PROT_ABORTED, PI_ERR_SOCK_INVALID, PI_LEVEL_CMP, pi_protocol(), pi_protocol_next(), pi_set_error(), pi_protocol::read, pi_socket::sd, pi_cmp_data::type, and pi_cmp_data::version.

Referenced by cmp_protocol(), cmp_rx_handshake(), and cmp_tx_handshake().

00348 {
00349         int     bytes;
00350         pi_protocol_t   *prot,
00351                         *next;
00352         struct  pi_cmp_data *data;
00353 
00354         LOG((PI_DBG_CMP, PI_DBG_LVL_DEBUG, "CMP RX len=%d flags=0x%02x\n",
00355                 len, flags));
00356 
00357         prot = pi_protocol(ps->sd, PI_LEVEL_CMP);
00358         if (prot == NULL)
00359                 return pi_set_error(ps->sd, PI_ERR_SOCK_INVALID);
00360 
00361         data = (struct pi_cmp_data *)prot->data;
00362         next = pi_protocol_next(ps->sd, PI_LEVEL_CMP);
00363         if (next == NULL)
00364                 return pi_set_error(ps->sd, PI_ERR_SOCK_INVALID);
00365 
00366         bytes = next->read(ps, msg, len, flags);
00367         if (bytes < 10)
00368                 return pi_set_error(ps->sd, (bytes < 0) ? bytes : PI_ERR_PROT_ABORTED);
00369 
00370         CHECK(PI_DBG_CMP, PI_DBG_LVL_INFO, cmp_dump(msg->data, 0));
00371 
00372         data->type      = get_byte(&msg->data[PI_CMP_OFFSET_TYPE]);
00373         data->flags     = get_byte(&msg->data[PI_CMP_OFFSET_FLGS]);
00374         data->version   = get_short(&msg->data[PI_CMP_OFFSET_VERS]);
00375         data->baudrate  = get_long(&msg->data[PI_CMP_OFFSET_BAUD]);
00376 
00377         return 0;
00378 }

Here is the call graph for this function:

int cmp_rx_handshake ( pi_socket_t ps,
int  establishrate,
int  establishhighrate 
)

Definition at line 185 of file cmp.c.

References pi_cmp_data::baudrate, buf, cmp_abort(), cmp_init(), cmp_rx(), pi_protocol::data, LOG, pi_buffer_free(), pi_buffer_new(), PI_CMP_HEADER_LEN, PI_DBG_CMP, PI_DBG_LVL_ERR, PI_DBG_LVL_INFO, PI_ERR_GENERIC_MEMORY, PI_ERR_PROT_INCOMPATIBLE, PI_ERR_SOCK_INVALID, PI_LEVEL_CMP, pi_protocol(), pi_set_error(), pi_socket::sd, and pi_cmp_data::version.

Referenced by pi_bluetooth_accept(), pi_inet_accept(), pi_serial_accept(), and pi_usb_accept().

00187 {
00188         pi_protocol_t *prot;
00189         struct  pi_cmp_data *data;
00190         pi_buffer_t *buf;
00191         int bytes;
00192 
00193         prot = pi_protocol(ps->sd, PI_LEVEL_CMP);
00194         if (prot == NULL)
00195                 return pi_set_error(ps->sd, PI_ERR_SOCK_INVALID);
00196 
00197         data = (struct pi_cmp_data *)prot->data;
00198 
00199         /* Read the cmp packet */
00200         buf = pi_buffer_new (PI_CMP_HEADER_LEN);
00201         if (buf == NULL) {
00202                 errno = ENOMEM;
00203                 return pi_set_error(ps->sd, PI_ERR_GENERIC_MEMORY);
00204         }
00205         
00206         bytes = cmp_rx(ps, buf, PI_CMP_HEADER_LEN, 0);
00207 
00208         pi_buffer_free (buf);
00209         if (bytes < 0)
00210                 return bytes;
00211 
00212         if ((data->version & 0xFF00) == 0x0100) {
00213                 if (establishrate != -1) {
00214                         if (establishrate > data->baudrate) {
00215                                 if (establishhighrate) {
00216                                         LOG((PI_DBG_CMP, PI_DBG_LVL_INFO, 
00217                                             "CMP Establishing higher rate %ul (%ul)\n",
00218                                             establishrate, data->baudrate));
00219                                         data->baudrate = establishrate;
00220                                 }
00221                         } else {
00222                                 data->baudrate = establishrate;
00223                         }
00224                 }
00225                 
00226                 if ((bytes = cmp_init(ps, data->baudrate)) < 0)
00227                         return bytes;
00228         } else {
00229                 /* 0x80 means the comm version wasn't compatible */
00230                 LOG((PI_DBG_CMP, PI_DBG_LVL_ERR, "CMP Incompatible Version\n"));
00231                 cmp_abort(ps, 0x80);
00232                 errno = ECONNREFUSED;
00233                 return pi_set_error(ps->sd, PI_ERR_PROT_INCOMPATIBLE);
00234         }
00235 
00236         return 0;
00237 }

Here is the call graph for this function:

static int cmp_setsockopt ( pi_socket_t ps,
int  level,
int  option_name,
const void *  option_value,
size_t *  option_len 
) [static]

Definition at line 579 of file cmp.c.

References pi_protocol::data, pisock::error, PI_ERR_GENERIC_ARGUMENT, PI_ERR_SOCK_INVALID, PI_LEVEL_PADP, PI_PADP_TYPE, pi_protocol(), pi_set_error(), pi_socket::sd, and pi_padp_data::type.

Referenced by cmp_protocol().

00581 {
00582         pi_protocol_t *prot;
00583         struct  pi_padp_data *data;
00584 
00585         (void) level;
00586 
00587         prot = pi_protocol(ps->sd, PI_LEVEL_PADP);
00588         if (prot == NULL)
00589                 return pi_set_error(ps->sd, PI_ERR_SOCK_INVALID);
00590         data = (struct pi_padp_data *)prot->data;
00591 
00592         if (option_name == PI_PADP_TYPE) {
00593                 if (*option_len != sizeof (data->type))
00594                         goto error;
00595                 memcpy (&data->type, option_value,
00596                         sizeof (data->type));
00597                 *option_len = sizeof (data->type);
00598         }
00599 
00600         return 0;
00601         
00602  error:
00603         errno = EINVAL;
00604         return pi_set_error(ps->sd, PI_ERR_GENERIC_ARGUMENT);
00605 }

Here is the call graph for this function:

ssize_t cmp_tx ( pi_socket_t ps,
const unsigned char *  buf,
size_t  len,
int  flags 
)

Definition at line 297 of file cmp.c.

References pi_cmp_data::baudrate, CHECK, cmp_dump(), pi_protocol::data, pi_cmp_data::flags, padData, PI_CMP_HEADER_LEN, PI_CMP_OFFSET_BAUD, PI_CMP_OFFSET_FLGS, PI_CMP_OFFSET_RESV, PI_CMP_OFFSET_TYPE, PI_CMP_OFFSET_VERS, PI_CMP_VERSION, PI_DBG_CMP, PI_DBG_LVL_INFO, PI_ERR_PROT_ABORTED, PI_ERR_SOCK_INVALID, PI_LEVEL_CMP, PI_LEVEL_PADP, PI_PADP_TYPE, pi_protocol(), pi_protocol_next(), pi_set_error(), pi_setsockopt(), pi_socket::sd, set_byte, set_long, set_short, size, pi_cmp_data::type, pi_cmp_data::version, and pi_protocol::write.

00298 {
00299         int     bytes,
00300                 type;
00301         size_t  size;
00302         pi_protocol_t   *prot,
00303                         *next;
00304         struct  pi_cmp_data *data;
00305         unsigned char cmp_buf[PI_CMP_HEADER_LEN];
00306 
00307         prot = pi_protocol(ps->sd, PI_LEVEL_CMP);
00308         if (prot == NULL)
00309                 return pi_set_error(ps->sd, PI_ERR_SOCK_INVALID);
00310 
00311         data = (struct pi_cmp_data *)prot->data;
00312         next = pi_protocol_next(ps->sd, PI_LEVEL_CMP);
00313         if (next == NULL)
00314                 return pi_set_error(ps->sd, PI_ERR_SOCK_INVALID);
00315 
00316         type = padData;
00317         size = sizeof(type);
00318         pi_setsockopt(ps->sd, PI_LEVEL_PADP, PI_PADP_TYPE, &type, &size);
00319 
00320         set_byte(&cmp_buf[PI_CMP_OFFSET_TYPE], data->type);
00321         set_byte(&cmp_buf[PI_CMP_OFFSET_FLGS], data->flags);
00322         set_short(&cmp_buf[PI_CMP_OFFSET_VERS], data->version > PI_CMP_VERSION ? PI_CMP_VERSION : data->version);
00323         set_short(&cmp_buf[PI_CMP_OFFSET_RESV], 0);
00324         set_long(&cmp_buf[PI_CMP_OFFSET_BAUD], data->baudrate);
00325 
00326         CHECK(PI_DBG_CMP, PI_DBG_LVL_INFO, cmp_dump(cmp_buf, 1));
00327 
00328         bytes = next->write(ps, cmp_buf, PI_CMP_HEADER_LEN, flags);
00329         if (bytes < 10)
00330                 return (bytes < 0) ? bytes : pi_set_error(ps->sd, PI_ERR_PROT_ABORTED);
00331 
00332         return 0;
00333 }

Here is the call graph for this function:

int cmp_tx_handshake ( pi_socket_t ps  ) 

Definition at line 252 of file cmp.c.

References cmp_rx(), cmp_wakeup(), pi_protocol::data, LOG, PI_CMP_TYPE_ABRT, PI_CMP_TYPE_INIT, PI_DBG_CMP, PI_DBG_LVL_NONE, PI_ERR_PROT_ABORTED, PI_ERR_PROT_INCOMPATIBLE, PI_ERR_SOCK_INVALID, PI_LEVEL_CMP, pi_protocol(), pi_set_error(), pi_socket::sd, and pi_cmp_data::type.

Referenced by pi_bluetooth_connect(), pi_inet_connect(), pi_serial_connect(), and pi_usb_connect().

00253 {
00254         pi_protocol_t *prot;
00255         struct  pi_cmp_data *data;
00256         int result;
00257 
00258         prot = pi_protocol(ps->sd, PI_LEVEL_CMP);
00259         if (prot == NULL)
00260                 return pi_set_error(ps->sd, PI_ERR_SOCK_INVALID);
00261 
00262         data = (struct pi_cmp_data *)prot->data;
00263 
00264         if ((result = cmp_wakeup(ps, 38400)) < 0)       /* Assume box can't go over 38400 */
00265                 return result;
00266 
00267         if ((result = cmp_rx(ps, NULL, 0, 0)) < 0)
00268                 return result;                                                  /* failed to read, errno already set */
00269 
00270         switch (data->type) {
00271                 case PI_CMP_TYPE_INIT:
00272                         return 0;
00273                 case PI_CMP_TYPE_ABRT:
00274                         LOG((PI_DBG_CMP, PI_DBG_LVL_NONE,
00275                                 "CMP Aborted by other end\n"));
00276                         errno = -EIO;
00277                         return pi_set_error(ps->sd, PI_ERR_PROT_ABORTED);
00278         }
00279 
00280         return PI_ERR_PROT_INCOMPATIBLE;
00281 
00282 }

Here is the call graph for this function:

int cmp_wakeup ( pi_socket_t ps,
int  maxbaud 
)

Definition at line 481 of file cmp.c.

References pi_cmp_data::baudrate, cmp_tx(), pi_protocol::data, pi_cmp_data::flags, PI_CMP_TYPE_WAKE, PI_CMP_VERSION, PI_ERR_SOCK_INVALID, PI_LEVEL_CMP, pi_protocol(), pi_set_error(), pi_socket::sd, pi_cmp_data::type, and pi_cmp_data::version.

Referenced by cmp_tx_handshake().

00482 {
00483         pi_protocol_t *prot;
00484         struct  pi_cmp_data *data;
00485         
00486         prot = pi_protocol(ps->sd, PI_LEVEL_CMP);
00487         if (prot == NULL)
00488                 return pi_set_error(ps->sd, PI_ERR_SOCK_INVALID);
00489 
00490         data = (struct pi_cmp_data *)prot->data;
00491         data->type      = PI_CMP_TYPE_WAKE;
00492         data->flags     = 0;
00493         data->version   = PI_CMP_VERSION;
00494         data->baudrate  = maxbaud;
00495 
00496         return cmp_tx(ps, NULL, 0, 0);
00497 }

Here is the call graph for this function:


© 1996-2007 by pilot-link.org. All rights reserved.