user/ec_command.c
branchkernel-2.4
changeset 1762 fd8b9ad48f88
parent 1761 d7ef8607e06f
child 1766 9e4d4306b641
equal deleted inserted replaced
1761:d7ef8607e06f 1762:fd8b9ad48f88
     1 //---------------------------------------------------------------
       
     2 //
       
     3 //  e c _ c o m m a n d . c
       
     4 //
       
     5 //  $LastChangedDate$
       
     6 //  $Author$
       
     7 //
       
     8 //---------------------------------------------------------------
       
     9 
       
    10 #include <stdio.h>
       
    11 #include <stdlib.h>
       
    12 
       
    13 #include "ec_command.h"
       
    14 
       
    15 //---------------------------------------------------------------
       
    16 
       
    17 void EtherCAT_command_init(EtherCAT_command_t *cmd)
       
    18 {
       
    19   cmd->command_type = 0x00;
       
    20   cmd->node_address = 0x0000;
       
    21   cmd->ring_position = 0x0000;
       
    22   cmd->mem_address = 0x0000;
       
    23   cmd->logical_address = 0x00000000;
       
    24   cmd->data_length = 0;
       
    25   cmd->status = Waiting;
       
    26   cmd->next = NULL;
       
    27   cmd->working_counter = 0;
       
    28   cmd->data = NULL;
       
    29 }
       
    30 
       
    31 //---------------------------------------------------------------
       
    32 
       
    33 void EtherCAT_command_clear(EtherCAT_command_t *cmd)
       
    34 {
       
    35   if (cmd->data)
       
    36   {
       
    37     free(cmd->data);
       
    38   }
       
    39 
       
    40   EtherCAT_command_init(cmd);
       
    41 }
       
    42 
       
    43 //---------------------------------------------------------------
       
    44 
       
    45 void EtherCAT_command_print_data(EtherCAT_command_t *cmd)
       
    46 {
       
    47   unsigned int i;
       
    48 
       
    49   printf("[");
       
    50 
       
    51   for (i = 0; i < cmd->data_length; i++)
       
    52   {
       
    53     printf("%02X", cmd->data[i]);
       
    54 
       
    55     if (i < cmd->data_length - 1) printf(" ");
       
    56   }
       
    57 
       
    58   printf("]\n");
       
    59 }
       
    60 
       
    61 //---------------------------------------------------------------