Commit 7dd8cd27 authored by Claes Sjofors's avatar Claes Sjofors

Profinet interface to Softing userspace stack

parent a8ca8e8e
......@@ -67,7 +67,7 @@ PnViewerPNAC::PnViewerPNAC( pwr_tStatus *sts, const char *dev_name)
local = new io_sAgentLocal;
pnak_init();
*sts = pnak_start_profistack(0, PNAK_CONTROLLER_MODE);
*sts = pnak_start_profistack(0, PNAK_SUPERVISOR_MODE);
if (*sts != PNAK_OK) {
printf("Starting profistack returned with error code\n");
......
/*
* Copyright (C) 2010 SSAB Oxelsund AB.
* Copyright (C) 2005-2015 SSAB EMEA AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -60,9 +60,9 @@ T_PNAK_RESULT pnak_get_alarm_ack_ind (unsigned short a1, T
/*--- Data interface functions ----------------------------------------------*/
T_PNAK_RESULT pnak_set_iocr_data (unsigned short a1, unsigned short a2, const unsigned char* a3, unsigned short a4) {return PNAK_OK;}
T_PNAK_RESULT pnak_set_iocr_data (unsigned short a1, unsigned short a2, const unsigned char* a3, unsigned short a4, unsigned char a5) {return PNAK_OK;}
T_PNAK_RESULT pnak_get_iocr_data (unsigned short a1, unsigned short a2, unsigned char* a3, unsigned short* a4, unsigned char* a5) {return PNAK_OK;}
T_PNAK_RESULT pnak_get_iocr_data (unsigned short a1, unsigned short a2, unsigned char* a3, unsigned short* a4, unsigned char* a5, unsigned char *a6) {return PNAK_OK;}
T_PNAK_RESULT pnak_get_consumer_data_changed_ind (unsigned short a1, T_PNAK_DATA_CONSUMER_DATA_CHANGED* a2) {return PNAK_OK;}
T_PNAK_RESULT pnak_get_provider_data_updated (unsigned short a1, T_PNAK_DATA_PROVIDER_DATA_UPDATED* a2) {return PNAK_OK;}
......
......@@ -74,7 +74,7 @@
static int count;
//static int count;
static pwr_tStatus IoAgentInit (
io_tCtx ctx,
......@@ -102,30 +102,9 @@ static pwr_tStatus IoAgentInit (
io_sAgent *ap
)
{
pwr_sClass_PnControllerSoftingPNAK *op;
pwr_tUInt16 sts;
io_sAgentLocal *local;
io_sPnRackLocal *r_local;
char fname[196];
char hname[40];
char *env;
vector<GsdmlDeviceData *> device_vect;
GsdmlDeviceData *dev_data;
PnDeviceData *pn_dev_data;
PnIOCRData *pn_iocr_data;
PnModuleData *pn_slot_data;
PnSubmoduleData *pn_subslot_data;
unsigned short ii, jj, kk, ll, offset_inputs, offset_outputs, type;
unsigned short num_modules = 0;
int s;
struct ifreq ifr = {};
io_sRack *slave_list;
count=0;
io_sAgentLocal *local;
pwr_sClass_PnControllerSoftingPNAK *op;
/* Allocate area for local data structure */
ap->Local = (io_sAgentLocal *) new io_sAgentLocal;
......@@ -135,288 +114,38 @@ static pwr_tStatus IoAgentInit (
}
local = (io_sAgentLocal *) ap->Local;
op = (pwr_sClass_PnControllerSoftingPNAK *) ap->op;
op->Status = PB__NOTINIT;
/* Initialize interface */
errh_Info( "Initializing interface for Profinet IO Master %s", ap->Name);
/* Add master as a device */
dev_data = new GsdmlDeviceData;
/* Get configs for device */
gethostname(hname, 40);
s = socket(AF_INET, SOCK_DGRAM, 0);
strncpy(ifr.ifr_name, op->EthernetDevice, sizeof(ifr.ifr_name));
if (ioctl(s, SIOCGIFADDR, &ifr) >= 0) {
strcpy(dev_data->ip_address, inet_ntoa(((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr));
}
if (ioctl(s, SIOCGIFNETMASK, &ifr) >= 0) {
strcpy(dev_data->subnet_mask, inet_ntoa(((struct sockaddr_in *) &ifr.ifr_netmask)->sin_addr));
}
sscanf(dev_data->ip_address, "%hhu.%hhu.%hhu.%hhu", &local->ipaddress[3], &local->ipaddress[2], &local->ipaddress[1], &local->ipaddress[0]) ;
sscanf(dev_data->subnet_mask, "%hhu.%hhu.%hhu.%hhu", &local->subnetmask[3], &local->subnetmask[2], &local->subnetmask[1], &local->subnetmask[0]) ;
strcpy(dev_data->device_name, hname);
dev_data->device_num = PN_DEVICE_REFERENCE_THIS_STATION;
strcpy(dev_data->device_text, op->EthernetDevice);
dev_data->vendor_id = 279; // Softing vendor id
dev_data->device_id = 0;
strcpy(dev_data->version, "1.0");
dev_data->byte_order = 0;
device_vect.push_back(dev_data);
pn_dev_data = new PnDeviceData;
pn_dev_data->device_ref = PN_DEVICE_REFERENCE_THIS_STATION;
local->device_data.push_back(pn_dev_data);
env = getenv("pwrp_load");
/* Iterate over the slaves. */
for (slave_list = ap->racklist, ii = 0; slave_list != NULL;
slave_list = slave_list->next, ii++) {
dev_data = new GsdmlDeviceData;
pn_dev_data = new PnDeviceData;
sprintf(fname, "%s/pwr_pn_%s.xml", env, cdh_ObjidToFnString(NULL, slave_list->Objid ));
dev_data->read(fname);
device_vect.push_back(dev_data);
pn_dev_data->device_ref = ii + 1;
for (jj = 0; jj < dev_data->iocr_data.size(); jj++) {
pn_iocr_data = new PnIOCRData;
pn_iocr_data->type = dev_data->iocr_data[jj]->type;
pn_dev_data->iocr_data.push_back(pn_iocr_data);
}
num_modules = 0;
for (jj = 0; jj < dev_data->slot_data.size(); jj++) {
if ((dev_data->slot_data[jj]->module_enum_number != 0) ||
(jj == 0))
num_modules++;
else break;
}
for (jj = 0; jj < num_modules; jj++) {
pn_slot_data = new PnModuleData;
pn_slot_data->slot_number = dev_data->slot_data[jj]->slot_number;
pn_slot_data->ident_number = dev_data->slot_data[jj]->module_ident_number;
pn_dev_data->module_data.push_back(pn_slot_data);
for (kk = 0; kk < dev_data->slot_data[jj]->subslot_data.size(); kk++) {
pn_subslot_data = new PnSubmoduleData;
pn_subslot_data->subslot_number = dev_data->slot_data[jj]->subslot_data[kk]->subslot_number;
pn_subslot_data->ident_number = dev_data->slot_data[jj]->subslot_data[kk]->submodule_ident_number;
pn_subslot_data->api = dev_data->slot_data[jj]->subslot_data[kk]->api;
if (dev_data->slot_data[jj]->subslot_data[kk]->io_input_length > 0) {
pn_subslot_data->io_in_data_length = dev_data->slot_data[jj]->subslot_data[kk]->io_input_length;
pn_subslot_data->type = PROFINET_IO_SUBMODULE_TYPE_INPUT ;
}
if (dev_data->slot_data[jj]->subslot_data[kk]->io_output_length > 0) {
pn_subslot_data->io_out_data_length = dev_data->slot_data[jj]->subslot_data[kk]->io_output_length;
pn_subslot_data->type |= PROFINET_IO_SUBMODULE_TYPE_OUTPUT;
}
if ((dev_data->slot_data[jj]->subslot_data[kk]->io_output_length > 0) &&
(dev_data->slot_data[jj]->subslot_data[kk]->io_input_length > 0)) {
pn_subslot_data->type |= PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT;
}
pn_dev_data->module_data[jj]->submodule_data.push_back(pn_subslot_data);
}
}
local->device_data.push_back(pn_dev_data);
}
/* Start profistack */
pnak_init();
sts = pnak_start_profistack(0, PNAK_CONTROLLER_MODE);
if (sts != PNAK_OK) {
op->Status = PB__INITFAIL;
errh_Error( "Starting profistack returned with error code: %d", sts);
return IO__ERRINIDEVICE;
}
/* Download configuration for all devices */
for (ii = 0; ii < device_vect.size(); ii++) {
// for (ii = 0; ii < 1; ii++) {
pack_download_req(&local->service_req_res, device_vect[ii], local->device_data[ii]->device_ref);
sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) {
sts = wait_service_con(local, ap);
if (sts == PNAK_OK) {
/* Loop through devices and calculate offset for io */
for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++) {
offset_inputs = 0;
offset_outputs = 0;
type = local->device_data[ii]->iocr_data[jj]->type;
for (kk = 0; kk < local->device_data[ii]->module_data.size(); kk++) {
for (ll = 0; ll < local->device_data[ii]->module_data[kk]->submodule_data.size(); ll++) {
PnSubmoduleData *submodule;
submodule = local->device_data[ii]->module_data[kk]->submodule_data[ll];
if ((type == PROFINET_IO_CR_TYPE_INPUT) &&
((submodule->type == PROFINET_IO_SUBMODULE_TYPE_INPUT) ||
(submodule->type == PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT))) {
submodule->offset_clean_io_in = offset_inputs;
offset_inputs += submodule->io_in_data_length;
}
else if ((type == PROFINET_IO_CR_TYPE_OUTPUT) &&
((submodule->type == PROFINET_IO_SUBMODULE_TYPE_OUTPUT) ||
(submodule->type == PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT))) {
submodule->offset_clean_io_out = offset_outputs;
offset_outputs += submodule->io_out_data_length;
}
}
}
local->device_data[ii]->iocr_data[jj]->clean_io_data = (unsigned char *) calloc(1, offset_inputs + offset_outputs);
local->device_data[ii]->iocr_data[jj]->clean_io_data_length = offset_inputs + offset_outputs;
}
} else {
errh_Error( "Download of Profinet Device configuration failed for: %s", device_vect[ii]->device_name);
/* Setup a dummy i/o area. Depending on exisiting channels this area needs to exist */
for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++) {
local->device_data[ii]->iocr_data[jj]->clean_io_data = (unsigned char *) calloc(1, PROFINET_IO_DATA_MAX_LENGTH);
}
}
}
}
/* Loop trough devices and set up i/o */
for (slave_list = ap->racklist, ii = 0; slave_list != NULL;
slave_list = slave_list->next, ii++) {
slave_list->Local = (unsigned char *) calloc(1, sizeof(io_sPnRackLocal));
r_local = (io_sPnRackLocal *) slave_list->Local;
for (jj = 0; jj < local->device_data[ii + 1]->iocr_data.size(); jj++) {
if (local->device_data[ii + 1]->iocr_data[jj]->type == PROFINET_IO_CR_TYPE_INPUT) {
r_local->bytes_of_input = local->device_data[ii + 1]->iocr_data[jj]->clean_io_data_length;
r_local->inputs = local->device_data[ii + 1]->iocr_data[jj]->clean_io_data;
}
else if (local->device_data[ii + 1]->iocr_data[jj]->type == PROFINET_IO_CR_TYPE_OUTPUT) {
r_local->bytes_of_output = local->device_data[ii + 1]->iocr_data[jj]->clean_io_data_length;
r_local->outputs = local->device_data[ii + 1]->iocr_data[jj]->clean_io_data;
}
}
}
/* Set identification */
pack_set_identification_req(&local->service_req_res);
sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) {
sts = wait_service_con(local, ap);
}
/* Set mode online */
T_PNAK_EVENT_SET_MODE pMode;
pMode.Mode = PNAK_MODE_ONLINE;
sts = pnak_set_mode(0, &pMode);
if (sts != PNAK_OK) {
op->Status = PB__INITFAIL;
errh_Error( "Profistack unable to go online, errcode: %d", sts);
return IO__ERRINIDEVICE;
}
T_PNAK_WAIT_OBJECT wait_object;
wait_object = PNAK_WAIT_OBJECT_STATE_CHANGED;
sts = pnak_wait_for_multiple_objects(0, &wait_object, PNAK_INFINITE_TIMEOUT);
if (sts == PNAK_OK) {
T_PNAK_EVENT_STATE pState;
sts = pnak_get_state(0, &pState);
if (pState.Mode != PNAK_MODE_ONLINE) {
if (sts != PNAK_OK) {
op->Status = PB__INITFAIL;
errh_Error( "Profistack unable to set state online, errcode: %d", sts);
return IO__ERRINIDEVICE;
}
}
}
/* Activate the devices */
T_PNAK_EVENT_SET_DEVICE_STATE set_dev_state;
unsigned short index, bit_no;
memset(&set_dev_state, 0, sizeof(set_dev_state));
for (ii = 0; ii < local->device_data.size(); ii++) {
index = ii / 8;
bit_no = ii % 8;
set_dev_state.ActivateDeviceReference[index] |= (1 << bit_no);
}
sts = pnak_set_device_state(0, &set_dev_state);
if (sts != PNAK_OK) {
op->Status = PB__INITFAIL;
errh_Error( "Profistack unable to activate devices, errcode: %d", sts);
return IO__ERRINIDEVICE;
}
/* Check state for all devices */
/* Active supervision thread */
for (ii = 1; ii < device_vect.size(); ii++) {
// for (ii = 0; ii < 1; ii++) {
pack_get_device_state_req(&local->service_req_res, local->device_data[ii]->device_ref);
pthread_attr_t attr;
sts = pnak_send_service_req_res(0, &local->service_req_res);
local->args.local = local;
local->args.ap = ap;
if (sts == PNAK_OK) {
sts = wait_service_con(local, ap);
}
}
op->Status = PB__NOTINIT;
pthread_mutexattr_t mutexattr;
pthread_condattr_t condattr;
/* Active supervision thread */
pthread_mutexattr_init(&mutexattr);
pthread_mutex_init(&local->mutex, &mutexattr);
pthread_mutexattr_destroy(&mutexattr);
pthread_attr_t attr;
pthread_condattr_init(&condattr);
pthread_cond_init(&local->cond, &condattr);
pthread_condattr_destroy(&condattr);
local->args.local = local;
local->args.ap = ap;
pthread_mutex_lock(&local->mutex);
pthread_attr_init(&attr);
pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
pthread_create(&local->handle_events, &attr, handle_events, &local->args);
pthread_cond_wait(&local->cond, &local->mutex);
pthread_mutex_unlock(&local->mutex);
op->Status = PB__NORMAL;
return IO__SUCCESS;
......@@ -437,6 +166,7 @@ static pwr_tStatus IoAgentRead (
unsigned char *clean_io_datap;
unsigned char status_data = 0;
PnSubmoduleData *submodule;
unsigned char ioxs;
unsigned short data_length, ii, jj, kk, ll;
......@@ -446,6 +176,9 @@ static pwr_tStatus IoAgentRead (
// handle_events(&local->args);
/* Read i/o for all devices and move it to clean io data area */
// pthread_mutex_lock(&local->mutex);
for (ii = 1; ii < local->device_data.size(); ii++) {
if (local->device_data[ii]->device_state == PNAK_DEVICE_STATE_CONNECTED) {
for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++) {
......@@ -455,7 +188,7 @@ static pwr_tStatus IoAgentRead (
if (pn_iocr_data->type == PROFINET_IO_CR_TYPE_INPUT) {
data_length = pn_iocr_data->io_data_length;
sts = pnak_get_iocr_data(0, pn_iocr_data->identifier, pn_iocr_data->io_data, &data_length, &status_data);
sts = pnak_get_iocr_data(0, pn_iocr_data->identifier, pn_iocr_data->io_data, &data_length, &ioxs, &status_data);
if (sts == PNAK_OK) {
for (kk = 0; kk < local->device_data[ii]->module_data.size(); kk++) {
......@@ -469,11 +202,16 @@ static pwr_tStatus IoAgentRead (
}
}
}
} else {
printf("pnak_get_iocr_data failed!\n");
}
}
}
}
}
// pthread_mutex_unlock(&local->mutex);
return IO__SUCCESS;
}
......@@ -496,7 +234,7 @@ static pwr_tStatus IoAgentWrite (
pwr_sClass_PnDevice *sp;
unsigned short data_length, ii, jj, kk, ll;
// unsigned char *status_datap;
//unsigned char *status_datap;
local = (io_sAgentLocal *) ap->Local;
......@@ -505,6 +243,8 @@ static pwr_tStatus IoAgentWrite (
/* Iterate over the slaves. */
slave_list = ap->racklist;
// pthread_mutex_lock(&local->mutex);
for (ii = 1; ii < local->device_data.size(); ii++) {
if (local->device_data[ii]->device_state == PNAK_DEVICE_STATE_CONNECTED) {
......@@ -528,13 +268,17 @@ static pwr_tStatus IoAgentWrite (
clean_io_datap = (pn_iocr_data->clean_io_data + submodule->offset_clean_io_out);
memcpy(io_datap, clean_io_datap, submodule->io_out_data_length);
/* status_datap = io_datap + submodule->io_out_data_length;
/*status_datap = io_datap + submodule->io_out_data_length;
*status_datap = PNAK_IOXS_STATUS_NO_EXTENTION_FOLLOWS | PNAK_IOXS_STATUS_DATA_GOOD;
*/
}
}
}
sts = pnak_set_iocr_data(0, pn_iocr_data->identifier, pn_iocr_data->io_data, pn_iocr_data->io_data_length);
char ioxs = CYCLIC_DATA_STATUS_DATA_VALID | CYCLIC_DATA_STATUS_STATE_PRIMARY | CYCLIC_DATA_STATUS_STATE_RUN | CYCLIC_DATA_STATUS_NORMAL_OPERATION;
sts = pnak_set_iocr_data(0, pn_iocr_data->identifier, pn_iocr_data->io_data, pn_iocr_data->io_data_length, ioxs);
if (sts != PNAK_OK) {
printf("pnak_set_iocr_data failed!\n");
}
}
}
......@@ -570,6 +314,8 @@ static pwr_tStatus IoAgentWrite (
}
}
// pthread_mutex_unlock(&local->mutex);
return IO__SUCCESS;
}
......
......@@ -192,6 +192,9 @@ class io_sAgentLocal {
pthread_t handle_events;
agent_args args;
pthread_mutex_t mutex;
pthread_cond_t cond;
};
#endif
......@@ -59,6 +59,13 @@
#include "rt_pn_gsdml_data.h"
#include "rt_io_base.h"
#include "rt_io_pnak_locals.h"
#include "rt_io_pn_locals.h"
#include "sys/socket.h"
#include "sys/ioctl.h"
#include "net/if.h"
#include "netinet/in.h"
#include "arpa/inet.h"
#define _PN_U32_HIGH_WORD(U32) ((PN_U16) ((U32) >> 16))
#define _PN_U32_LOW_WORD(U32) ((PN_U16) (U32) )
......@@ -1229,7 +1236,7 @@ int unpack_get_device_state_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal
printf(
"channel %d: download.con [-] (%d)\r\n"
"channel %d: get_device_state.con [-] (%d)\r\n"
" code : %d (0x%02x)\r\n"
" detail : %d (0x%02x)\r\n"
" add. detail: %d (0x%02x)\r\n"
......@@ -1652,15 +1659,312 @@ void *handle_events(void *ptr) {
T_PNAK_WAIT_OBJECT wait_object;
int sts;
pwr_sClass_PnControllerSoftingPNAK *op;
// pwr_tUInt16 sts;
io_sPnRackLocal *r_local;
char fname[196];
char hname[40];
char *env;
vector<GsdmlDeviceData *> device_vect;
GsdmlDeviceData *dev_data;
PnDeviceData *pn_dev_data;
PnIOCRData *pn_iocr_data;
PnModuleData *pn_slot_data;
PnSubmoduleData *pn_subslot_data;
unsigned short ii, jj, kk, ll, offset_inputs, offset_outputs, type;
unsigned short num_modules = 0;
int s;
struct ifreq ifr = {};
io_sRack *slave_list;
args = (agent_args *) ptr;
local = (io_sAgentLocal *) args->local;
ap = args->ap;
// count=0;
pthread_mutex_lock(&local->mutex);
op = (pwr_sClass_PnControllerSoftingPNAK *) ap->op;
/* Initialize interface */
errh_Info( "Initializing interface for Profinet IO Master %s", ap->Name);
/* Add master as a device */
dev_data = new GsdmlDeviceData;
/* Get configs for device */
gethostname(hname, 40);
s = socket(AF_INET, SOCK_DGRAM, 0);
strncpy(ifr.ifr_name, op->EthernetDevice, sizeof(ifr.ifr_name));
if (ioctl(s, SIOCGIFADDR, &ifr) >= 0) {
strcpy(dev_data->ip_address, inet_ntoa(((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr));
}
if (ioctl(s, SIOCGIFNETMASK, &ifr) >= 0) {
strcpy(dev_data->subnet_mask, inet_ntoa(((struct sockaddr_in *) &ifr.ifr_netmask)->sin_addr));
}
sscanf(dev_data->ip_address, "%hhu.%hhu.%hhu.%hhu", &local->ipaddress[3], &local->ipaddress[2], &local->ipaddress[1], &local->ipaddress[0]) ;
sscanf(dev_data->subnet_mask, "%hhu.%hhu.%hhu.%hhu", &local->subnetmask[3], &local->subnetmask[2], &local->subnetmask[1], &local->subnetmask[0]) ;
strcpy(dev_data->device_name, hname);
dev_data->device_num = PN_DEVICE_REFERENCE_THIS_STATION;
strcpy(dev_data->device_text, op->EthernetDevice);
dev_data->vendor_id = 279; // Softing vendor id
dev_data->device_id = 0;
strcpy(dev_data->version, "1.0");
dev_data->byte_order = 0;
device_vect.push_back(dev_data);
pn_dev_data = new PnDeviceData;
pn_dev_data->device_ref = PN_DEVICE_REFERENCE_THIS_STATION;
local->device_data.push_back(pn_dev_data);
env = getenv("pwrp_load");
/* Iterate over the slaves. */
for (slave_list = ap->racklist, ii = 0; slave_list != NULL;
slave_list = slave_list->next, ii++) {
dev_data = new GsdmlDeviceData;
pn_dev_data = new PnDeviceData;
sprintf(fname, "%s/pwr_pn_%s.xml", env, cdh_ObjidToFnString(NULL, slave_list->Objid ));
dev_data->read(fname);
device_vect.push_back(dev_data);
pn_dev_data->device_ref = ii + 1;
for (jj = 0; jj < dev_data->iocr_data.size(); jj++) {
pn_iocr_data = new PnIOCRData;
pn_iocr_data->type = dev_data->iocr_data[jj]->type;
pn_dev_data->iocr_data.push_back(pn_iocr_data);
}
num_modules = 0;
for (jj = 0; jj < dev_data->slot_data.size(); jj++) {
if ((dev_data->slot_data[jj]->module_enum_number != 0) ||
(jj == 0))
num_modules++;
else break;
}
for (jj = 0; jj < num_modules; jj++) {
pn_slot_data = new PnModuleData;
pn_slot_data->slot_number = dev_data->slot_data[jj]->slot_number;
pn_slot_data->ident_number = dev_data->slot_data[jj]->module_ident_number;
pn_dev_data->module_data.push_back(pn_slot_data);
for (kk = 0; kk < dev_data->slot_data[jj]->subslot_data.size(); kk++) {
pn_subslot_data = new PnSubmoduleData;
pn_subslot_data->subslot_number = dev_data->slot_data[jj]->subslot_data[kk]->subslot_number;
pn_subslot_data->ident_number = dev_data->slot_data[jj]->subslot_data[kk]->submodule_ident_number;
pn_subslot_data->api = dev_data->slot_data[jj]->subslot_data[kk]->api;
if (dev_data->slot_data[jj]->subslot_data[kk]->io_input_length > 0) {
pn_subslot_data->io_in_data_length = dev_data->slot_data[jj]->subslot_data[kk]->io_input_length;
pn_subslot_data->type = PROFINET_IO_SUBMODULE_TYPE_INPUT ;
}
if (dev_data->slot_data[jj]->subslot_data[kk]->io_output_length > 0) {
pn_subslot_data->io_out_data_length = dev_data->slot_data[jj]->subslot_data[kk]->io_output_length;
pn_subslot_data->type |= PROFINET_IO_SUBMODULE_TYPE_OUTPUT;
}
if ((dev_data->slot_data[jj]->subslot_data[kk]->io_output_length > 0) &&
(dev_data->slot_data[jj]->subslot_data[kk]->io_input_length > 0)) {
pn_subslot_data->type |= PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT;
}
pn_dev_data->module_data[jj]->submodule_data.push_back(pn_subslot_data);
}
}
local->device_data.push_back(pn_dev_data);
}
/* Start profistack */
sts = pnak_start_profistack(0, PNAK_CONTROLLER_MODE);
if (sts != PNAK_OK) {
op->Status = PB__INITFAIL;
errh_Error( "Starting profistack returned with error code: %d", sts);
// return IO__ERRINIDEVICE;
}
/* Download configuration for all devices */
for (ii = 0; ii < device_vect.size(); ii++) {
// for (ii = 0; ii < 1; ii++) {
pack_download_req(&local->service_req_res, device_vect[ii], local->device_data[ii]->device_ref);
sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) {
sts = wait_service_con(local, ap);
if (sts == PNAK_OK) {
/* Loop through devices and calculate offset for io */
for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++) {
offset_inputs = 0;
offset_outputs = 0;
type = local->device_data[ii]->iocr_data[jj]->type;
for (kk = 0; kk < local->device_data[ii]->module_data.size(); kk++) {
for (ll = 0; ll < local->device_data[ii]->module_data[kk]->submodule_data.size(); ll++) {
PnSubmoduleData *submodule;
submodule = local->device_data[ii]->module_data[kk]->submodule_data[ll];
if ((type == PROFINET_IO_CR_TYPE_INPUT) &&
((submodule->type == PROFINET_IO_SUBMODULE_TYPE_INPUT) ||
(submodule->type == PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT))) {
submodule->offset_clean_io_in = offset_inputs;
offset_inputs += submodule->io_in_data_length;
}
else if ((type == PROFINET_IO_CR_TYPE_OUTPUT) &&
((submodule->type == PROFINET_IO_SUBMODULE_TYPE_OUTPUT) ||
(submodule->type == PROFINET_IO_SUBMODULE_TYPE_INPUT_AND_OUTPUT))) {
submodule->offset_clean_io_out = offset_outputs;
offset_outputs += submodule->io_out_data_length;
}
}
}
local->device_data[ii]->iocr_data[jj]->clean_io_data = (unsigned char *) calloc(1, offset_inputs + offset_outputs);
local->device_data[ii]->iocr_data[jj]->clean_io_data_length = offset_inputs + offset_outputs;
}
} else {
errh_Error( "Download of Profinet Device configuration failed for: %s", device_vect[ii]->device_name);
/* Setup a dummy i/o area. Depending on exisiting channels this area needs to exist */
for (jj = 0; jj < local->device_data[ii]->iocr_data.size(); jj++) {
local->device_data[ii]->iocr_data[jj]->clean_io_data = (unsigned char *) calloc(1, PROFINET_IO_DATA_MAX_LENGTH);
}
}
}
}
/* Loop trough devices and set up i/o */
for (slave_list = ap->racklist, ii = 0; slave_list != NULL;
slave_list = slave_list->next, ii++) {
slave_list->Local = (unsigned char *) calloc(1, sizeof(io_sPnRackLocal));
r_local = (io_sPnRackLocal *) slave_list->Local;
for (jj = 0; jj < local->device_data[ii + 1]->iocr_data.size(); jj++) {
if (local->device_data[ii + 1]->iocr_data[jj]->type == PROFINET_IO_CR_TYPE_INPUT) {
r_local->bytes_of_input = local->device_data[ii + 1]->iocr_data[jj]->clean_io_data_length;
r_local->inputs = local->device_data[ii + 1]->iocr_data[jj]->clean_io_data;
}
else if (local->device_data[ii + 1]->iocr_data[jj]->type == PROFINET_IO_CR_TYPE_OUTPUT) {
r_local->bytes_of_output = local->device_data[ii + 1]->iocr_data[jj]->clean_io_data_length;
r_local->outputs = local->device_data[ii + 1]->iocr_data[jj]->clean_io_data;
}
}
}
/* Set identification */
pack_set_identification_req(&local->service_req_res);
sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) {
sts = wait_service_con(local, ap);
}
/* Set mode online */
T_PNAK_EVENT_SET_MODE pMode;
pMode.Mode = PNAK_MODE_ONLINE;
sts = pnak_set_mode(0, &pMode);
if (sts != PNAK_OK) {
op->Status = PB__INITFAIL;
errh_Error( "Profistack unable to go online, errcode: %d", sts);
// return IO__ERRINIDEVICE;
}
// T_PNAK_WAIT_OBJECT wait_object;
wait_object = PNAK_WAIT_OBJECT_STATE_CHANGED;
sts = pnak_wait_for_multiple_objects(0, &wait_object, PNAK_INFINITE_TIMEOUT);
if (sts == PNAK_OK) {
T_PNAK_EVENT_STATE pState;
sts = pnak_get_state(0, &pState);
if (pState.Mode != PNAK_MODE_ONLINE) {
if (sts != PNAK_OK) {
op->Status = PB__INITFAIL;
errh_Error( "Profistack unable to set state online, errcode: %d", sts);
// return IO__ERRINIDEVICE;
}
}
}
/* Activate the devices */
T_PNAK_EVENT_SET_DEVICE_STATE set_dev_state;
unsigned short index, bit_no;
memset(&set_dev_state, 0, sizeof(set_dev_state));
for (ii = 0; ii < local->device_data.size(); ii++) {
index = ii / 8;
bit_no = ii % 8;
set_dev_state.ActivateDeviceReference[index] |= (1 << bit_no);
}
sts = pnak_set_device_state(0, &set_dev_state);
if (sts != PNAK_OK) {
op->Status = PB__INITFAIL;
errh_Error( "Profistack unable to activate devices, errcode: %d", sts);
// return IO__ERRINIDEVICE;
}
/* Check state for all devices */
for (ii = 1; ii < device_vect.size(); ii++) {
// for (ii = 0; ii < 1; ii++) {
pack_get_device_state_req(&local->service_req_res, local->device_data[ii]->device_ref);
sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) {
sts = wait_service_con(local, ap);
}
}
pthread_cond_signal(&local->cond);
pthread_mutex_unlock(&local->mutex);
/* Do forever ... */
while (1) {
wait_object = PNAK_WAIT_OBJECTS_EVENT_IND | PNAK_WAIT_OBJECTS_OTHER | PNAK_WAIT_OBJECT_SERVICE_CON;
// pthread_mutex_lock(&local->mutex);
sts = pnak_wait_for_multiple_objects(0, &wait_object, PNAK_INFINITE_TIMEOUT);
if (sts == PNAK_OK) {
......@@ -1713,6 +2017,9 @@ void *handle_events(void *ptr) {
printf("Running == NOT !!");
// pThisSmObject->Running = PN_FALSE;
}
// pthread_mutex_unlock(&local->mutex);
}
return 0;
}
......
/******************************************************************************
SOFTING AG
SOFTING Industrial Automation GmbH
Richard-Reitzner-Allee 6
D-85540 Haar
Phone: ++49-89-4 56 56-0
Fax: ++49-89-4 56 56-3 99
http://www.softing.com
Copyright (C) SOFTING AG 2005-2009. All Rights Reserved
Copyright (C) SOFTING Industrial Automation GmbH 2005-2013. All Rights Reserved
Version: 1.60.0.00.release
Version: 2.01.00
******************************************************************************/
......@@ -30,8 +30,7 @@ Version: 1.60.0.00.release
#define PACK_BYTE_ALIGNMENT(Struct) Struct
#endif
#else
#ifdef __GNUC__
#elif defined __GNUC__
#ifndef PACK_WORD_ALIGNMENT
#define PACK_WORD_ALIGNMENT(Struct) __attribute__ ((packed, aligned (2))) Struct
#endif
......@@ -39,21 +38,32 @@ Version: 1.60.0.00.release
#ifndef PACK_BYTE_ALIGNMENT
#define PACK_BYTE_ALIGNMENT(Struct) __attribute__ ((packed, aligned (1))) Struct
#endif
#else
#error CAUTION: set word structure alignment
#elif defined _OS9000
#ifndef PACK_WORD_ALIGNMENT
#define PACK_WORD_ALIGNMENT(Struct) Struct
#endif
#ifndef PACK_BYTE_ALIGNMENT
#define PACK_BYTE_ALIGNMENT(Struct) Struct
#endif
#else
#error CAUTION: set word structure alignment
#endif
/******************************************************************************
ACCESS KIT USER INTERFACE
******************************************************************************/
#define MAX_NUMBER_SUPPORTED_DEVICES (PN_U16) 256u
#define _BITSET256_RESET_BIT(pBS,BitNr) (((pBS)) [(BitNr) >> 3] &= ~(1u << ((BitNr) & 7u)))
#define _BITSET256_SET_BIT(pBS,BitNr) (((pBS)) [(BitNr) >> 3] |= 1u << ((BitNr) & 7u) )
#define _BITSET256_IS_BIT_SET(pBS,BitNr) ((((pBS)) [(BitNr) >> 3]) & (1u << ((BitNr) & 7u) ))
#define _BITSET64_RESET_BIT(pBS,BitNr) (((pBS)) [(BitNr) >> 3] &= ~(1u << ((BitNr) & 7u)))
#define _BITSET64_SET_BIT(pBS,BitNr) (((pBS)) [(BitNr) >> 3] |= 1u << ((BitNr) & 7u) )
#define _BITSET64_IS_BIT_SET(pBS,BitNr) ((((pBS)) [(BitNr) >> 3]) & (1u << ((BitNr) & 7u) ))
/*---------------------------------------------------------------------------*/
#ifndef _MAX
......@@ -124,13 +134,29 @@ typedef enum _T_PNAK_RESULT
PNAK_ERR_SNMP_NOT_WRITABLE,
PNAK_ERR_SNMP_INCONSISTENT_NAME,
PNAK_ERR_SNMP_CONTEXT_NO_SUCH_OBJECT,
PNAK_ERR_SNMP_CONTEXT_NO_SUCH_INSTANCE
PNAK_ERR_SNMP_CONTEXT_NO_SUCH_INSTANCE,
/*--- errors for watchdog handling ----------------------------------------*/
PNAK_ERR_WATCHDOG_EXPIRED,
PNAK_ERR_WATCHDOG_ACCESS_DENIED,
PNAK_ERR_INVALID_WATCHDOG_UPDATE_COUNT,
/*--- errors of hardware checks -------------------------------------------*/
PNAK_ERR_HW_FLASH_CKECK_FAILED,
PNAK_ERR_HW_RAM_CKECK_FAILED,
/*--- errors loading library -------------------------------------------*/
PNAK_ERR_LIBRARY_NOT_LOADED,
} T_PNAK_RESULT;
/*---------------------------------------------------------------------------*/
typedef unsigned char T_BITSET_256 [32];
typedef unsigned char T_BITSET_64 [8];
/*---------------------------------------------------------------------------*/
......@@ -149,7 +175,7 @@ typedef struct _T_PNAK_EXCEPTION
unsigned short FileId;
unsigned short ErrorId;
unsigned long UserSpecificParameter;
PN_U32 UserSpecificParameter;
char UserString [22];
} PACK_WORD_ALIGNMENT (T_PNAK_EXCEPTION);
......@@ -198,8 +224,8 @@ typedef struct _T_PNAK_VERSIONS
#define PNAK_INFINITE_TIMEOUT 0xFFFFFFFFuL
#define PNAK_MAX_NUMBER_WAIT_OBJECTS 32uL
typedef unsigned long T_PNAK_TIMEOUT;
typedef unsigned long T_PNAK_WAIT_OBJECT;
typedef PN_U32 T_PNAK_TIMEOUT;
typedef PN_U32 T_PNAK_WAIT_OBJECT;
#define PNAK_WAIT_OBJECT_EXCEPTION ((T_PNAK_WAIT_OBJECT) 0x00000001uL)
#define PNAK_WAIT_OBJECT_STATE_CHANGED ((T_PNAK_WAIT_OBJECT) 0x00000002uL)
......@@ -212,6 +238,9 @@ typedef unsigned long T_PNAK_WAIT_OBJECT;
#define PNAK_WAIT_OBJECT_SERVICE_IND ((T_PNAK_WAIT_OBJECT) 0x00000100uL)
#define PNAK_WAIT_OBJECT_SERVICE_CON ((T_PNAK_WAIT_OBJECT) 0x00000200uL)
#define PNAK_WAIT_OBJECT_SERVICE_REQ_RES_HANDLED ((T_PNAK_WAIT_OBJECT) 0x00000400uL)
#define PNAK_WAIT_OBJECT_PTCP ((T_PNAK_WAIT_OBJECT) 0x00000800uL)
#define PNAK_WAIT_OBJECT_SOCKET_STATE_CHANGED ((T_PNAK_WAIT_OBJECT) 0x00001000uL)
#define PNAK_WAIT_OBJECT_SOCKET_DATA_RECEIVED ((T_PNAK_WAIT_OBJECT) 0x00002000uL)
#define PNAK_WAIT_OBJECT_CHANNEL_CLOSED ((T_PNAK_WAIT_OBJECT) 0x00200000uL)
#define PNAK_WAIT_OBJECT_INTERRUPTED ((T_PNAK_WAIT_OBJECT) 0x00400000uL)
#define PNAK_USER_WAIT_OBJECT_1 ((T_PNAK_WAIT_OBJECT) 0x00800000uL)
......@@ -231,9 +260,12 @@ typedef unsigned long T_PNAK_WAIT_OBJECT;
PNAK_WAIT_OBJECT_ALARM | \
PNAK_WAIT_OBJECT_ALARM_ACK | \
PNAK_WAIT_OBJECT_DEVICE_STATE_CHANGED | \
PNAK_WAIT_OBJECT_ETHERNET_STATE_CHANGED)
PNAK_WAIT_OBJECT_ETHERNET_STATE_CHANGED | \
PNAK_WAIT_OBJECT_PTCP)
#define PNAK_WAIT_OBJECTS_DATA_IND (PNAK_WAIT_OBJECT_PROVIDER_DATA_UPDATED |\
PNAK_WAIT_OBJECT_CONSUMER_DATA_CHANGED)
#define PNAK_WAIT_OBJECTS_SOCKET_IND (PNAK_WAIT_OBJECT_SOCKET_STATE_CHANGED | \
PNAK_WAIT_OBJECT_SOCKET_DATA_RECEIVED)
#define PNAK_WAIT_OBJECTS_OTHER (PNAK_WAIT_OBJECT_EXCEPTION | \
PNAK_WAIT_OBJECT_CHANNEL_CLOSED | \
PNAK_WAIT_OBJECT_INTERRUPTED)
......@@ -249,6 +281,7 @@ typedef unsigned long T_PNAK_WAIT_OBJECT;
PNAK_WAIT_OBJECTS_EVENT_IND | \
PNAK_WAIT_OBJECTS_DATA_IND | \
PNAK_WAIT_OBJECTS_SERVICE | \
PNAK_WAIT_OBJECTS_SOCKET_IND | \
PNAK_WAIT_OBJECTS_USER | \
PNAK_WAIT_TIMEOUT)
......@@ -390,7 +423,9 @@ typedef enum _T_PNAK_STATE
PNAK_STATE_APPL_WATCHDOG_EXPIRED,
PNAK_STATE_ETH_FAILURE,
PNAK_STATE_UDP_FAILURE,
PNAK_STATE_DUPLICATE_NAME_ERROR
PNAK_STATE_DUPLICATE_NAME_ERROR,
PNAK_STATE_SPEED_OR_DUPLEXITY_PROBLEM,
PNAK_STATE_NON_VOLATILE_STORAGE_PROBLEM
} T_PNAK_STATE;
......@@ -439,15 +474,28 @@ typedef struct _T_PNAK_EVENT_DEVICE_STATE
} PACK_WORD_ALIGNMENT (T_PNAK_EVENT_DEVICE_STATE);
/*---------------------------------------------------------------------------*/
#define PNAK_PTCP_IN_SNYC 0x00000001uL
#define PNAK_PTCP_NO_SYNC_MESSAGE 0x00000002uL
#define PNAK_PTCP_JITTER_OUT_OF_BOUNDARY 0x00000004uL
/*=== EVENT INDICATION MASK =================================================*/
#define PNAK_EVENT_STATE_CHANGED 0x00000001uL
#define PNAK_EVENT_DEVICE_STATE_CHANGED 0x00000002uL
#define PNAK_EVENT_ALARM 0x00000004uL
#define PNAK_EVENT_ALARM_ACK 0x00000008uL
#define PNAK_EVENT_ETHERNET_STATE_CHANGED 0x00000010uL
#define PNAK_EVENT_PTCP 0x00000020uL
#define PNAK_EVENT_MASK (PNAK_EVENT_STATE_CHANGED | \
PNAK_EVENT_DEVICE_STATE_CHANGED | \
PNAK_EVENT_ALARM | \
PNAK_EVENT_DEVICE_STATE_CHANGED)
typedef unsigned long T_PNAK_EVENT_REG;
PNAK_EVENT_ALARM_ACK | \
PNAK_EVENT_ETHERNET_STATE_CHANGED | \
PNAK_EVENT_PTCP)
typedef PN_U32 T_PNAK_EVENT_REG;
typedef struct _T_PNAK_EVENT_IND_MASK
{
......@@ -455,6 +503,31 @@ typedef struct _T_PNAK_EVENT_IND_MASK
} PACK_WORD_ALIGNMENT (T_PNAK_EVENT_IND_MASK);
/*=============================================================================
STATISTIC INTERFACE
=============================================================================*/
/* Attention: keep in sync with data provided by stack, see controller context management */
#define PNAK_CMCTL_VENDOR_ID_MISMATCH 0x00000001uL
#define PNAK_CMCTL_DEVICE_ID_MISMATCH 0x00000002uL
#define PNAK_CMCTL_DUPLICATE_NAME 0x00000004uL
#define PNAK_CMCTL_DUPLICATE_IP_ADDRESS 0x00000008uL
#define PNAK_CMCTL_NO_EMPTY_NAME 0x00000010uL
#define PNAK_CMCTL_RPC_RESPONSE_MISSING 0x00000020uL
#define PNAK_CMCTL_MODULE_MISMATCH 0x00000040uL
typedef struct _T_PNAK_CMCTL_STATISTIC
{
PN_U32 NumberDevicesInStartup;
PN_U32 NumberDevicesConnected;
T_PN_MAC_ADDRESS MacAddress [MAX_NUMBER_SUPPORTED_DEVICES];
T_PROFINET_STATUS PNIOStatus [MAX_NUMBER_SUPPORTED_DEVICES];
PN_U32 Status [MAX_NUMBER_SUPPORTED_DEVICES];
} T_PNAK_CMCTL_STATISTIC;
/*=============================================================================
DATA INTERFACE
=============================================================================*/
......@@ -481,7 +554,7 @@ typedef struct _T_PNAK_DATA_PROVIDER_DATA_UPDATED
#define PNAK_DATA_EVENT_CONSUMER_DATA_CHANGED 0x00000002uL
#define PNAK_DATA_EVENT_PROVIDER_DATA_UPDATED 0x00000004uL
typedef unsigned long T_PNAK_DATA_EVENT_REG;
typedef PN_U32 T_PNAK_DATA_EVENT_REG;
typedef struct _T_PNAK_DATA_IND_MASK
{
......@@ -501,13 +574,13 @@ typedef struct _T_PNAK_DATA_IND_MASK
/*---------------------------------------------------------------------------*/
/* now we support only one controller-device and
* one supervisor-device connection, if we want later
/* now we support only 2 controller-device, 1 configuration in run and
* 1 supervisor-device connection, if we want later
* also support further connections we must increase
* the max number and add specific statemachines in the
* object data structure
*/
#define MAX_NUMBER_CMDEV_CONNECTIONS 2u
#define MAX_NUMBER_CMDEV_CONNECTIONS 4u
/******************************************************************************
FUNCTION DECLARATION
......@@ -517,13 +590,18 @@ FUNCTION DECLARATION
extern "C" {
#endif
#ifndef __DOXYGEN__
/*--- initialization/termination functions ----------------------------------*/
extern void pnak_init (void);
extern void pnak_term (void);
extern T_PNAK_RESULT pnak_start_profistack (unsigned short, const T_PNAK_MODE_ID);
extern T_PNAK_RESULT pnak_stop_profistack (unsigned short);
#define pnak_start_profistack pnak_start_stack
#define pnak_stop_profistack pnak_stop_stack
extern T_PNAK_RESULT pnak_start_stack (unsigned short, const T_PNAK_MODE_ID);
extern T_PNAK_RESULT pnak_stop_stack (unsigned short);
/*--- General interface functions -------------------------------------------*/
......@@ -534,12 +612,16 @@ extern T_PNAK_RESULT pnak_mask_multiple_objects (unsigned shor
extern T_PNAK_RESULT pnak_get_exception (unsigned short, T_PNAK_EXCEPTION*);
extern T_PNAK_RESULT pnak_get_version (unsigned short, T_PNAK_VERSIONS*);
extern T_PNAK_RESULT pnak_snmp_get_data (unsigned short, T_PNAK_OID*, void*, unsigned long*, unsigned long*, unsigned char, PN_BOOL);
extern T_PNAK_RESULT pnak_snmp_check_data (unsigned short, T_PNAK_OID*, void*, unsigned long, unsigned long, unsigned char);
extern T_PNAK_RESULT pnak_snmp_set_data (unsigned short, T_PNAK_OID*, void*, unsigned long, unsigned long);
extern T_PNAK_RESULT pnak_snmp_get_data (unsigned short, T_PNAK_OID*, void*, PN_U32*, PN_U32*, unsigned char, PN_BOOL);
extern T_PNAK_RESULT pnak_snmp_check_data (unsigned short, T_PNAK_OID*, void*, PN_U32, PN_U32, unsigned char);
extern T_PNAK_RESULT pnak_snmp_set_data (unsigned short, T_PNAK_OID*, void*, PN_U32, PN_U32);
extern T_PNAK_RESULT pnak_retrigger_watchdog (unsigned short, PN_U32);
/*--- Service interface functions -------------------------------------------*/
extern T_PNAK_RESULT pnak_limit_number_parallel_services (unsigned short, unsigned short, unsigned short);
extern T_PNAK_RESULT pnak_send_service_req_res (unsigned short, const T_PNAK_SERVICE_REQ_RES*);
extern T_PNAK_RESULT pnak_get_service_ind (unsigned short, T_PNAK_SERVICE_IND*);
extern T_PNAK_RESULT pnak_get_service_con (unsigned short, T_PNAK_SERVICE_CON*);
......@@ -553,12 +635,13 @@ extern T_PNAK_RESULT pnak_get_state (unsigned shor
extern T_PNAK_RESULT pnak_get_device_state_ind (unsigned short, T_PNAK_EVENT_DEVICE_STATE*);
extern T_PNAK_RESULT pnak_get_alarm_ind (unsigned short, T_PNAK_EVENT_ALARM*);
extern T_PNAK_RESULT pnak_get_alarm_ack_ind (unsigned short, T_PNAK_EVENT_ALARM_ACK*);
extern T_PNAK_RESULT pnak_get_ptcp_ind (unsigned short, PN_U32*);
/*--- Data interface functions ----------------------------------------------*/
extern T_PNAK_RESULT pnak_set_iocr_data (unsigned short, unsigned short, const unsigned char*, unsigned short);
extern T_PNAK_RESULT pnak_set_iocr_data (unsigned short, unsigned short, const unsigned char*, unsigned short, unsigned char);
extern T_PNAK_RESULT pnak_get_iocr_data (unsigned short, unsigned short, unsigned char*, unsigned short*, unsigned char*);
extern T_PNAK_RESULT pnak_get_iocr_data (unsigned short, unsigned short, unsigned char*, unsigned short*, unsigned char*, unsigned char*);
extern T_PNAK_RESULT pnak_get_consumer_data_changed_ind (unsigned short, T_PNAK_DATA_CONSUMER_DATA_CHANGED*);
extern T_PNAK_RESULT pnak_get_provider_data_updated (unsigned short, T_PNAK_DATA_PROVIDER_DATA_UPDATED*);
......@@ -569,8 +652,8 @@ CALLBACK INTERFACE
typedef int (*T_PNAK_WAIT_OBJECT_CALLBACK) (unsigned short, T_PNAK_WAIT_OBJECT);
typedef int (*T_PNAK_HW_START_CALLBACK) (unsigned short, T_PNAK_MODE_ID, void*);
typedef void (*T_PROVIDER_CALLBACK) (unsigned short, unsigned short, unsigned char*, unsigned short);
typedef void (*T_CONSUMER_CALLBACK) (unsigned short, unsigned short, const unsigned char*, unsigned short, unsigned char);
typedef void (*T_PROVIDER_CALLBACK) (unsigned short, unsigned short, unsigned char*, unsigned short, unsigned char*);
typedef void (*T_CONSUMER_CALLBACK) (unsigned short, unsigned short, const unsigned char*, unsigned short, unsigned char, unsigned char);
extern T_PNAK_RESULT pnak_register_provider_callback (unsigned short, T_PROVIDER_CALLBACK);
extern T_PNAK_RESULT pnak_unregister_provider_callback (unsigned short);
......@@ -578,22 +661,566 @@ extern T_PNAK_RESULT pnak_unregister_provider_callback (unsigned shor
extern T_PNAK_RESULT pnak_register_consumer_callback (unsigned short, T_CONSUMER_CALLBACK);
extern T_PNAK_RESULT pnak_unregister_consumer_callback (unsigned short);
extern T_PNAK_RESULT pnak_register_ethernet_provider_hook (unsigned short, T_PROVIDER_CALLBACK);
extern T_PNAK_RESULT pnak_unregister_ethernet_provider_hook (unsigned short);
/*---------------------------------------------------------------------------*/
typedef void (*T_PNAK_CMCTL_STATISTIC_CALLBACK) (unsigned short, T_PNAK_CMCTL_STATISTIC*);
extern T_PNAK_RESULT pnak_register_cmctl_statistic_callback (unsigned short, T_PNAK_CMCTL_STATISTIC_CALLBACK);
extern T_PNAK_RESULT pnak_unregister_cmctl_statistic_callback (unsigned short);
#endif /* __DOXYGEN__ */
#ifdef __cplusplus
}
#endif
/* the scai/sdai socket functions are derived from the basic implementation of
* the PROFINET stack and use the same data structures and error codes
* so we have to disable the original definitions
*/
#if !defined (SCAI_INCLUDE_SOCKET) && !defined(SDAI_INCLUDE_SOCKET)
/******************************************************************************
SOCKET USER INTERFACE
******************************************************************************/
/**
* @socketmainpage
*
* @section Introduction
* In addition to the realtime ethernet communication via the PROFINET Application Interface (PNAK)
* Softing offers a universal Socket Interface for implementation of any TCP or UDP based protocol. It
* enables the integration of various industrial IT functions into the device:
*
* - Embedded Webserver for freely designed websites
* - FTP-Server for updating the device firmware or for file downloads
* - E-Mail client for sending E-Mails from the application program
* - Telnet for virtual terminal connections
* - Implementation of manufacturer specific application protocols
*
* The Socket Interface offers a comfortable application interface which disburdens the user from a lot of
* tasks and provides a lot of automatisms. The special characteristics of each TCP/IP stack will be hidden
* from the user. Establishment and management of TCP connections are handled completely by the socket interface.
* The user can focus on the implementation of the desired IT functionality. This allows an easy implementation
* of the socket application. The resources needed by the socket interface (see also \ref SocketResources) can be
* easily adpated to the available memory provided by the used the hardware platform.
*
* The communication via the Socket Interface can be used in parallel and without influencing the realtime
* communication via the used realtime ethernet protocol. Therefore the realtime ethernet communication
* will be processed with a higher priority than the communication via the Socket Interface. The network interface
* is shared between the Socket Interface and the realtime ethernet protocol. Thus a high communication load
* to be processed by the realtime ethernet protocol limits the available bandwith and the performance of the
* Socket Interface communication.
*
* @section Application Interface Description
* The following figure shows the structure of Softings Socket Interface implementation.
* @image html Socket_Structure.png
* A detailed description of the Socket Application Interface can be found in the following chapters:
* - \ref sock_defines
* - \ref sock_structures
* - \ref sock_functions
*/
/**
* @defgroup sock_defines Defines
* @ingroup sock
*/
/**
* @defgroup sock_structures Data Structures
* @ingroup sock
*/
/**
* @defgroup sock_functions Functions
* @ingroup sock
*/
/** \addtogroup sock_defines
* @{
*/
#define MAX_NUMBER_SUPPORTED_SOCKETS (PN_U16) 64u
/*--- Socket options --------------------------------------------------------*/
/** \anchor SocketFlags @name Socket Flags
* Definitions for Socket Flags
* @{
*/
#define SOCK_FLAG_TYPE_UDP 0x00000000uL /**< Socket type TCP */
#define SOCK_FLAG_TYPE_TCP 0x00008000uL /**< Socket type UDP */
#define SOCK_FLAG_ENABLE_KEEPALIVE (SOCK_FLAG_TYPE_TCP | 0x00000001uL) /**< Enables keep-alive packets to supervise a TCP connection */
#define SOCK_FLAG_ENABLE_BROADCAST (SOCK_FLAG_TYPE_UDP | 0x00000002uL) /**< Enables the transmission of broadcast messages over a UDP socket */
#define SOCK_FLAG_ENABLE_MULTICAST (SOCK_FLAG_TYPE_UDP | 0x00000004uL) /**< Enables the transmission of multicast messages over a UDP socket */
#define SOCK_FLAG_USER_MASK 0x0000FFFFuL /**< Specifies the bits wich are valid for the socket application */
/** @} */
/*--- Socket error codes ----------------------------------------------------*/
/** \anchor ErrorCode @name Socket Interface Error Codes
* Definitions for Socket Interface Error Codes
* @{
*/
typedef enum _T_SOCKET_RESULT
{
SOCK_SUCCESS = 0u, /**< General success return value */
SOCK_ERR_INVALID_ARGUMENT, /**< Passed argument is invalid */
SOCK_ERR_API_ALREADY_INITIALIZED, /**< Socket Interface already initialized */
SOCK_ERR_API_NOT_INITIALIZED, /**< Socket Interface not initialized */
SOCK_ERR_INVALID_SOCKET_ID, /**< The passed socket ID is invalid */
SOCK_ERR_OUT_OF_SOCKETS, /**< No free socket available */
SOCK_ERR_SOCKET_NOT_CREATED, /**< The specified socket has not been created. */
SOCK_ERR_SOCKET_OFFLINE, /**< The local port associated with the socket is not open. Sending/Receiving of messages is not possible. */
SOCK_ERR_SOCKET_BUSY, /**< A send request is rejected because a previous send request on the specified socket is not completed */
SOCK_ERR_SOCKET_NOT_CONNECTED, /**< The request is rejected because the specified TCP connection or no TCP connection has been established for the specified socket. */
SOCK_ERR_SOCKET_CONNECTED, /**< The request is rejected because the specified TCP connection has established a connection before the filter was activated. */
SOCK_ERR_ADDR_IN_USE, /**< The passed local address is already in use by another socket. */
SOCK_ERR_INVALID_LOCAL_ADDR, /**< The passed local IP address is invalid. It is not possible to bind the socket to this address. Which IP addresses are allowed depends
on the socket configuration (e.g. socket type UDP or TCP) and the network settings adjusted by calling the function sock_init(). */
SOCK_ERR_INVALID_REMOTE_ADDR, /**< The passed remote IP address is invalid. It is not possible to send or connect to this address. Which IP addresses are allowed depends
on the socket configuration (e.g. socket type UDP or TCP) and the network settings adjusted by calling the function sock_init(). */
SOCK_ERR_NO_DATA_RECEIVED, /**< No data has been received on the specfied socket or TCP connection. */
SOCK_ERR_NOT_SUPPORTED, /**< The requested action is not supported on the specified socket. */
SOCK_ERR_TEMPORARY_NOT_EXECUTABLE, /**< The requested action is temporary not executable on the specified socket due a concurrent pending request. */
SOCK_ERR_FATAL_ERROR, /**< A fatal error is reported during execution of function. */
SOCK_ERR_LIBRARY_NOT_LOADED /**< Can not load socket library */
} T_SOCKET_RESULT;
/** @} */
/*---------------------------------------------------------------------------*/
#define SOCK_IP_ADDR_ANY 0x00000000uL /**< Can be used as local IP address when creating a socket to bind the socket to all the IP addresses (If the system has
multiple IP addresses) or if the local IP address is unknown. */
#define SOCK_PORT_ANY 0u /**< Can be used as local port when creating a TCP Client socket to let the TCP/IP stack select a unique local port from the
dynamic client port range. */
/** @} */
/*===========================================================================*/
/** \addtogroup sock_structures Data Structures
* @{
* \brief Specifies a transport IP address and port.
* All of the structure data must be specified in network-byte-order (big-endian).
*/
typedef struct _T_PNAK_SOCK_ADDR
{
PN_U32 IpAddress; /**< IP address */
unsigned short Port; /**< port number */
unsigned char Alignment [2];
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_ADDR);
/** @} */
/*---------------------------------------------------------------------------*/
/** \addtogroup sock_structures Data Structures
* @{
* \brief Configurable Options for the socket interface
*/
typedef struct _T_PNAK_SOCK_CONFIG_OPTIONS
{
PN_U32 Timeout; /**< Keep-Alive Timeout in milliseconds. The Keep-Alive Timeout will be used for the supervision of TCP connections. The connection will be aborted if the
remote connection partner did not show activity within this timeout. The supervision of TCP connections can be enabled/disabled socket-specific when
creating the socket by calling sock_create(). For UDP sockets the application needs to perform a supervision if necessary. If the timeout value is set to 0
and #SOCK_FLAG_ENABLE_KEEPALIVE is set when creating a socket, a default value for the Keep-Alive Timeout will be used. */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_CONFIG_OPTIONS);
/** @} */
/*---------------------------------------------------------------------------*/
/** \addtogroup sock_structures Data Structures
* @{
* \brief Network specific parameter
* All of the structure data must be specified in network-byte-order (big-endian).
*/
typedef struct _T_PNAK_SOCK_NETWORK_SETTINGS
{
PN_U32 IpAddress; /**< The IP-Address of the Device. For future use only. */
PN_U32 SubnetMask; /**< The Netmask of the Device. For future use only. */
PN_U32 GatewayAddress; /**< The Gateway of the Device. For future use only. */
unsigned char MacAddress [6]; /**< The MAC address of the device. For future use only. */
unsigned char Alignment [2];
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_NETWORK_SETTINGS);
/** @} */
/*---------------------------------------------------------------------------*/
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure holds the initialization data for the socket interface
*/
typedef struct _T_PNAK_SOCK_INIT
{
T_PNAK_SOCK_NETWORK_SETTINGS NetworkSettings; /**< Network specific parameter */
T_PNAK_SOCK_CONFIG_OPTIONS ConfigOptions; /**< Configurable Options for the socket interface */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_INIT);
/** @} */
/*---------------------------------------------------------------------------*/
/** \addtogroup sock_defines
* @{
* \anchor ConnectionStatus @name TCP Connection Status
* Status of a TCP connection
* @{
*/
#define SOCK_TCP_CONNECTION_STATUS_UNCONNECTED 0x00000001uL /**< TCP connection not established */
#define SOCK_TCP_CONNECTION_STATUS_CONNECTING 0x00000002uL /**< A TCP connection establishment is in progress. This status is only possible for a TCP client socket. */
#define SOCK_TCP_CONNECTION_STATUS_CONNECTED 0x00000003uL /**< TCP connection established */
/** @} */
/** \anchor ConnectionStatusCode @name TCP Connection Status Codes
* Error Codes of a TCP connection
* @{
*/
#define SOCK_TCP_CONNECTION_STATUS_CODE_NO_ERROR 0x00000000uL /**< No error detected */
#define SOCK_TCP_CONNECTION_STATUS_CODE_INTERNAL_ERROR 0x00000001uL /**< An internal error occurred in the socket interface causing the connection to abort. */
#define SOCK_TCP_CONNECTION_STATUS_CODE_CLOSED_REMOTELY 0x00000002uL /**< The connection has been orderly closed by the remote connection partner (TCP FIN received). */
#define SOCK_TCP_CONNECTION_STATUS_CODE_ABORTED_REMOTELY 0x00000003uL /**< The connection has been aborted by the remote connection partner (TCP RST received), e.g. because
the remote partner has detected an error or temporarily crashed. */
#define SOCK_TCP_CONNECTION_STATUS_CODE_TIMEOUT 0x00000004uL /**< The connection has been aborted because of a network failure or because the remote connection partner failed
to respond within the configured supervision timeout (see also T_PNAK_SOCK_CONFIG_OPTIONS). */
#define SOCK_TCP_CONNECTION_STATUS_CODE_CONNECT_REJECTED 0x00000005uL /**< It was not possible to establish a connection because the destination host rejected the connect request,
e.g. because the remote port is closed. This error only occurs for a TCP client socket. To retry connection
establishment the application has to close the socket and re-create the socket again. */
/** @} */
/** @} */
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure holds status informations about a single TCP connection
*/
typedef struct _T_PNAK_SOCK_TCP_CONNECTION_LOCAL_STATUS
{
PN_U32 Status; /**< Local status of the TCP connection. Valid values: \ref ConnectionStatus */
PN_U32 StatusCode; /**< Indicates the last error of the TCP connection. Valid values: \ref ConnectionStatusCode */
T_PNAK_SOCK_ADDR RemoteAddr; /**< Address information of the remote connection partner */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_TCP_CONNECTION_LOCAL_STATUS);
/** @} */
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure holds status informations about all TCP connections of a socket
*/
typedef struct _T_PNAK_SOCK_TCP_LOCAL_STATUS_DATA
{
PN_U32 NumberConnections; /**< Number of TCP connection for which status info is provided */
/*T_PNAK_SOCK_TCP_CONNECTION_LOCAL_STATUS Connection [NumberConnections];*/ /**< TCP connection status information */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_TCP_LOCAL_STATUS_DATA);
/** @} */
/** \addtogroup sock_defines
* @{
* \anchor SocketStatus @name Socket Status
* Status of a socket
* @{
*/
#define SOCK_LOCAL_STATUS_CLOSED 0x00000001uL /**< The local socket is closed */
#define SOCK_LOCAL_STATUS_OFFLINE 0x00000002uL /**< The local port associated with the socket is not open. Sending/Receiving of messages is not possible. */
#define SOCK_LOCAL_STATUS_ONLINE 0x00000003uL /**< The local port associated with the socket is open. Sending/Receiving of messages is possible. */
/** @} */
/** \anchor SocketStatusCode @name Socket Status Codes
* Error Codes of a socket
* @{
*/
#define SOCK_LOCAL_STATUS_CODE_NO_ERROR 0x00000000uL /**< No error detected */
#define SOCK_LOCAL_STATUS_CODE_ADDR_IN_USE 0x00000001uL /**< The local address passed with sock_create() is already in use by another socket. */
#define SOCK_LOCAL_STATUS_CODE_INTERNAL_ERROR 0x00000002uL /**< An internal error occurred in the socket interface causing the socket to close. */
/** @} */
/** @} */
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure holds status informations about a socket
*/
typedef struct _T_PNAK_SOCK_IOC_GET_LOCAL_STATUS
{
PN_U32 Status; /**< Common socket status information. Valid values: \ref SocketStatus */
PN_U32 StatusCode; /**< Common socket error code. Valid values: \ref SocketStatusCode */
union
{
T_PNAK_SOCK_TCP_LOCAL_STATUS_DATA Tcp; /**< TCP specific socket status information */
/* UDP specific socket status information not existing */
} UseAs;
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_IOC_GET_LOCAL_STATUS);
/** @} */
/*---------------------------------------------------------------------------*/
/** \addtogroup sock_defines
* @{
* \anchor SendStatus @name Send Status
* Send Status of a socket
* @{
*/
#define SOCK_SEND_STATUS_NOT_BUSY 0x00000001uL /**< No send request produced by the application */
#define SOCK_SEND_STATUS_BUSY 0x00000002uL /**< The send request is in progress. */
/** @} */
/** \anchor SendStatusCode @name Send Status Codes
* Send Error Codes
* @{
*/
#define SOCK_SEND_STATUS_CODE_NO_ERROR 0x00000000uL /**< No error detected */
#define SOCK_SEND_STATUS_CODE_NO_BUFFERS 0x00000001uL /**< The TCP/IP stack was unable to allocate an internal buffer or the output queue is full. */
#define SOCK_SEND_STATUS_CODE_HOST_UNREACHABLE 0x00000002uL /**< The destination host is unreachable, e.g. the destination host is down */
#define SOCK_SEND_STATUS_CODE_REJECTED 0x00000003uL /**< The destination host rejected the message, e.g. remote port is closed.
This error can only be returned by TCP sockets. */
#define SOCK_SEND_STATUS_CODE_SEND_ERROR 0x00000004uL /**< The TCP/IP stack reported a general problem sending the message. */
/** @} */
/** @} */
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure holds TCP specific send status informations
*/
typedef struct _T_PNAK_SOCK_TCP_SEND_STATUS_DATA
{
T_PNAK_SOCK_ADDR RemoteAddr; /**< Address information of the remote connection partner */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_TCP_SEND_STATUS_DATA);
/** @} */
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure holds send status informations
*/
typedef struct _T_PNAK_SOCK_IOC_GET_SEND_STATUS
{
PN_U32 Status; /**< Common send status information. Valid values: \ref SendStatus */
PN_U32 StatusCode; /**< Common send error code. Valid values: \ref SendStatusCode */
union
{
T_PNAK_SOCK_TCP_SEND_STATUS_DATA Tcp; /**< TCP specific send status information */
/* UDP specific send status information not existing */
} UseAs;
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_IOC_GET_SEND_STATUS);
/** @} */
/*---------------------------------------------------------------------------*/
/** \addtogroup sock_defines
* @{
* \anchor ReceiveStatus @name Receive Status
* Receive Status of a socket
* @{
*/
#define SOCK_RECEIVE_STATUS_NO_DATA_RECEIVED 0x00000000uL /**< No data on the specfied socket or TCP connection has been received. */
#define SOCK_RECEIVE_STATUS_DATA_RECEIVED 0x00000001uL /**< New data has been received on the specfied socket or TCP connection. */
/** @} */
/** \anchor ReceiveStatusCode @name Receive Status Codes
* Receive Error Codes
* @{
*/
#define SOCK_RECEIVE_STATUS_CODE_NO_ERROR 0x00000000uL /**< No error detected */
/** @} */
/** @} */
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure holds TCP specific receive status informations
*/
typedef struct _T_PNAK_SOCK_TCP_RECEIVE_STATUS_DATA
{
T_PNAK_SOCK_ADDR RemoteAddr; /**< Address information of the remote connection partner */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_TCP_RECEIVE_STATUS_DATA);
/** @} */
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure holds receive status informations
*/
typedef struct _T_PNAK_SOCK_IOC_GET_RECEIVE_STATUS
{
PN_U32 Status; /**< Common receive status information. Valid values: \ref ReceiveStatus */
PN_U32 StatusCode; /**< Common receive error code. Valid values: \ref ReceiveStatusCode */
union
{
T_PNAK_SOCK_TCP_RECEIVE_STATUS_DATA Tcp; /**< TCP specific receive status information */
/* UDP specific send status information not existing */
} UseAs;
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_IOC_GET_RECEIVE_STATUS);
/** @} */
/*---------------------------------------------------------------------------*/
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure specifies the TCP connection which shall be aborted
*/
typedef struct _T_PNAK_SOCK_IOC_CLOSE_TCP_CONNECTION
{
T_PNAK_SOCK_ADDR RemoteAddr; /**< Address information of the remote connection partner */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_IOC_CLOSE_TCP_CONNECTION);
/** @} */
/*---------------------------------------------------------------------------*/
#define SOCK_MAX_NUMBER_FILTER_ENTRIES 4u
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure specifies the IP addresses from which a connection establishment shall be accepted
*/
typedef struct _T_PNAK_SOCK_IOC_TCP_ACCEPT_FILTER
{
PN_U16 NumberEntries; /**< number of filter entries */
PN_U16 Alignment;
PN_U32 Filter [SOCK_MAX_NUMBER_FILTER_ENTRIES]; /**< IP address */
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_IOC_TCP_ACCEPT_FILTER);
/** @} */
/*---------------------------------------------------------------------------*/
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure specifies the IP addresses of the multicast group the application wants to join or leave
*/
typedef struct _T_PNAK_SOCK_IOC_MULTICAST
{
PN_U32 IpAddress;
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_IOC_MULTICAST);
/*---------------------------------------------------------------------------*/
/** \addtogroup sock_defines
* @{
* \anchor IoctlCommand @name IO Control Commands
* IO Control Commands for a socket
* @{
*/
#define SOCK_IOC_GET_LOCAL_STATUS 0x00000001uL /**< Get the local socket status */
#define SOCK_IOC_GET_SEND_STATUS 0x00000002uL /**< Get the status of a send request */
#define SOCK_IOC_GET_RECEIVE_STATUS 0x00000003uL /**< Checks if new data has been received */
#define SOCK_IOC_CLOSE_TCP_CONNECTION 0x00000004uL /**< Closes a TCP connection */
#define SOCK_IOC_TCP_ACCEPT_FILTER 0x00000005uL /**< Defines which IP Addresses are accepted by the socket */
#define SOCK_IOC_UDP_ADD_MULTICAST 0x00000006uL /**< Join a multicast group */
#define SOCK_IOC_UDP_DEL_MULTICAST 0x00000007uL /**< Leave a multicast group */
/** @} */
/** @} */
/** \addtogroup sock_structures Data Structures
* @{
* \brief This structure holds the data for an IO Control Command
*/
typedef struct _T_PNAK_SOCK_IO_CONTROL
{
PN_U32 Command; /**< Specifies the IO Control Command. Valid values: \ref IoctlCommand */
union
{
T_PNAK_SOCK_IOC_GET_LOCAL_STATUS GetLocalStatus; /**< Local Socket Status informations */
T_PNAK_SOCK_IOC_GET_SEND_STATUS GetSendStatus; /**< Send Status informations */
T_PNAK_SOCK_IOC_GET_RECEIVE_STATUS GetReceiveStatus; /**< Receive Status informations */
T_PNAK_SOCK_IOC_CLOSE_TCP_CONNECTION CloseTcpConnection; /**< TCP connection which shall be closed */
T_PNAK_SOCK_IOC_TCP_ACCEPT_FILTER TcpAcceptFilter; /**< IP Address which shall be able to connect to the server */
T_PNAK_SOCK_IOC_MULTICAST AddMulticast; /**< Multicast group to join */
T_PNAK_SOCK_IOC_MULTICAST DelMulticast; /**< Multicast group to leave */
} UseAs;
} PACK_WORD_ALIGNMENT (T_PNAK_SOCK_IO_CONTROL);
/** @} */
/******************************************************************************
FUNCTION DECLARATION
******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __DOXYGEN__
/*--- initialization/termination functions ----------------------------------*/
extern T_SOCKET_RESULT pnak_sock_init (unsigned short, T_PNAK_SOCK_INIT*);
extern T_SOCKET_RESULT pnak_sock_term (unsigned short);
/*--- socket interface functions --------------------------------------------*/
extern T_SOCKET_RESULT pnak_sock_create (unsigned short, PN_U32, T_PNAK_SOCK_ADDR*, T_PNAK_SOCK_ADDR*, unsigned short*);
extern T_SOCKET_RESULT pnak_sock_close (unsigned short, unsigned short);
extern T_SOCKET_RESULT pnak_sock_send (unsigned short, unsigned short, T_PNAK_SOCK_ADDR*, PN_U16, const unsigned char*);
extern T_SOCKET_RESULT pnak_sock_receive (unsigned short, unsigned short, T_PNAK_SOCK_ADDR*, PN_U16*, unsigned char*);
extern T_SOCKET_RESULT pnak_sock_ioctl (unsigned short, unsigned short, T_PNAK_SOCK_IO_CONTROL*);
/*--- socket interface helper functions -------------------------------------*/
extern T_SOCKET_RESULT pnak_sock_get_receive_status (unsigned short, T_BITSET_64*);
#endif /* __DOXYGEN__ */
#ifdef __cplusplus
}
#endif
#endif /* SCAI_INCLUDE_SOCKET || SDAI_INCLUDE_SOCKET */
/*****************************************************************************/
#if defined WIN32 || defined _WIN32
#pragma warning (disable : 4103) /* used #pragma pack to reset alignment */
#pragma pack(pop)
#pragma warning (default : 4103)
#else
#ifdef __GNUC__
#elif defined __GNUC__
/* nothing to do */
#elif defined _OS9000
/* nothing to do */
#else
#else
#error CAUTION: set default structure alignment
#endif
#endif
/*****************************************************************************/
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -462,7 +462,7 @@ else
pwre_config_check_lib libhdf5 LIBHDF5 lib lib 0 "/usr/lib/libhdf5.so:/usr/lib/$hwpl-linux-$gnu/libhdf5.so"
pwre_config_check_lib mq MQ lib mq 1 "/usr/lib/libdmq.so:/usr/local/dmq/lib/libdmq.so"
pwre_config_check_lib wmq WMQ lib wmq 1 "/usr/lib/libmqic.so"
pwre_config_check_lib libpnioif PNAK lib pnak 1 "/usr/lib/libpnioif.a:/usr/local/lib/libpnioif.a"
pwre_config_check_lib libprofinet PNAK lib pnak 1 "/usr/lib/libprofinet.a"
pwre_config_check_lib libusb LIBUSB lib libusb 1 "/usr/lib/libusb-1.0.so:/usr/lib/$hwpl-linux-$gnu/libusb-1.0.so"
pwre_config_check_lib powerlink POWERLINK lib powerlink 1 "$epl/build/Examples/X86/Generic/powerlink_user_lib/libpowerlink.a"
pwre_config_check_lib powerlinkcn POWERLINKCN lib powerlinkcn 1 "$epl/buildcn/Examples/X86/Generic/powerlink_user_lib/libpowerlink.a"
......
......@@ -2146,7 +2146,7 @@ pwr_tStatus lfu_SaveDirectoryVolume(
sprintf( &str[strlen(str)], "-lpwr_rt ");
if ( bop->SystemModules & pwr_mBuildOptionsMask_SoftingPNAK)
sprintf( &str[strlen(str)], "-lpnioif ");
sprintf( &str[strlen(str)], "-lprofinet ");
else
sprintf( &str[strlen(str)], "-lpwr_pnak_dummy ");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment