Commit e164feaf authored by Guilherme Sanches's avatar Guilherme Sanches

Update on configure tool

Both the configure tool and the the xml files associated with the
iop_can example have been changed. Errors were corrected on both sets of
files.
parent 3e927a85
......@@ -70,14 +70,13 @@ SPWHEADER_ADDRESS = 'Address'
CANHEADER = 'CanHeader'
CANHEADER_EXTENDED = 'Extended'
CANHEADER_RTR = 'RTR'
CANHEADER_SSHOT = 'SSHOT'
CANHEADER_ID = 'CANId'
CANHEADER_ID = 'CanID'
import utils.parser as parserutils
VALID_STR = [ str, lambda x : len(x) ]
VALID_NAME_TlYPE = [ str, lambda x : 0 < len(x) < 31 ]
VALID_NAME_TYPE = [ str, lambda x : 0 < len(x) < 31 ]
VALID_DEVICE_ID_TYPE = [ parserutils.str2int, lambda x : x >= 0 ]
VALID_PORT = [ parserutils.str2int, lambda x : x > 0]
VALID_IP = [ lambda x: str(x).strip().split('.'), lambda x: len(x) == 4 ]
......@@ -87,14 +86,16 @@ VALID_FLOAT_TYPE = [ parserutils.str2float, lambda x : x >= 0 ]
VALID_DECIMAL_TYPE = [ parserutils.str2int, lambda x : x >= 0 ]
VALID_BOOLEAN_TYPE = [ parserutils.str2bool, lambda x : isinstance(x, bool) ]
VALID_DIRECTION_TYPE = [ str, lambda x : x in [ REMOTE_PORT_SRC, REMOTE_PORT_DST] ]
VALID_ID = [ lambda x: x > 0]
VALID_ID = [ parserutils.str2int, lambda x: x > 0]
VALID_MASK_CODE = [ lambda x: str(x).strip().split(':'), lambda x: len(x) == 4]
LOGICAL_DEVICE_STR = 'Logical Device (Id: {0}, Name: {1})'
PHYSICAL_DEVICE_STR = 'Physical Device (Id: {0}, Device: {1})'
ETH_HEADER_STR = 'Ethernet Header (Mac: {0}, Ip: {1}, Port: {2})'
SPW_HEADER_STR = 'SpaceWire Header (Address: {0})'
CAN_HEADER_STR = 'Canbus Header (extended: {0}, Rtr: {1}, Sshot: {2}, CanId: {3})'
CAN_HEADER_STR = 'Canbus Header (extended: {0}, Rtr: {1}, CanId: {2})'
REMOTE_PORT_STR = 'Remote Port (Name: {0})'
ROUTE_STR = 'Route (Id: {0})'
ROUTE_PHYSICAL_STR = 'Physical Route (Id: {0})'
......@@ -270,11 +271,10 @@ class SpwHeader(object):
return self.__str__()
## CANBUS Header
class CANHeader(object):
class CanHeader(object):
def __init__(self):
self.extended = 0
self.extended = False
self.rtr = 0
self.sshot = 0
self.can_id = 0
def __eq__(self, other):
......@@ -285,7 +285,8 @@ class CANHeader(object):
return not self.__eq__(other)
def __str__(self):
return CAN_HEADER_STR.format(self.extended, self.rtr, self.sshot, self.can_id)
return CAN_HEADER_STR.format(self.extended, \
self.rtr, self.can_id)
def __repr__(self):
return self.__str__()
......
......@@ -2,6 +2,7 @@
# @author pfnf
# modified by lumm and gmvs
# @brief Functions to parse gaisler devices
from sqlalchemy.sql.expression import false
__author__ = 'pfnf'
__modified__ = 'lumm'
......@@ -164,7 +165,7 @@ class OCCANPhySetup(object):
def details(self):
return 'CAN Physical Device Setup (CanID: {0} Speed: {1} TXD: {2} RXD: {3} InternalQueue: {4} SingleMode: {5} Code: {6} Mask: {7})'\
.format(bin(self.can_id), bin(self.speed), bin(self.txd), bin(self.rxd), bin(self.internal_queue), bin(int(self.single_mode)), bin(self.code), bin(self.masks))
.format(self.can_id, self.speed, self.txd, self.rxd, self.internal_queue, self.single_mode, ':'.join(self.code), ':'.join(self.mask))
# CANBUS Schedule device setup
class OCCANSchSetup(object):
......@@ -330,9 +331,9 @@ def phy_occan(iop_parser, xml, pdevices):
setup.txd_count = xml.parse_attr(CANBUS_TXD, VALID_XD, True, iop_parser.logger)
setup.rxd_count = xml.parse_attr(CANBUS_RXD, VALID_XD, True, iop_parser.logger)
setup.internal_queue = xml.parse_attr(CANBUS_INTERNAL_QUEUE, VALID_READS, True, iop_parser.logger)
setup.single_mode = xml.parse_attr(CANBUS_SINGLE_MODE, VALID_BOOL, True, iop_parser.logger)
setup.code = xml.parse_attr(CANBUS_CODE, VALID_MASK, True, iop_parser.logger)
setup.mask = xml.parse_attr(CANBUS_MASK, VALID_MASK, True, iop_parser.logger)
setup.single_mode = xml.parse_attr(CANBUS_SINGLE_MODE, VALID_BOOLEAN_TYPE, True, iop_parser.logger)
setup.code = xml.parse_attr(CANBUS_CODE, VALID_MASK_CODE, True, iop_parser.logger)
setup.mask = xml.parse_attr(CANBUS_MASK, VALID_MASK_CODE, True, iop_parser.logger)
# sanity check
if iop_parser.logger.check_errors(): return False
......@@ -349,7 +350,7 @@ def sch_occan(iop_parser, xml, pdevice):
iop_parser.logger.clear_errors(0)
# parse setup
setup = CANBUSchSetup()
setup = OCCANSchSetup()
setup.reads = xml.parse_attr(CANBUS_READS, VALID_READS, True, iop_parser.logger)
# sanity check
......
......@@ -324,14 +324,17 @@ class IOParser(object):
xml_header = xml.parse_tag(ETHHEADER, 1, 1, self.logger)
if self.logger.check_errors(): return None
return self.parse_eth_header(xml_header)
# device of spacewire type
elif pdevice.type == SPW:
xml_header = xml.parse_tag(SPWHEADER, 1, 1, self.logger)
if self.logger.check_errors(): return None
return self.parse_spw_header(xml_header)
# device of canbus type
elif pdevice.type == CAN:
xml_header = xml.parse_tag(CANHEADER, 1, 1, self.logger)
if self.logger.check_errprs(): return None
if self.logger.check_errors(): return None
return self.parse_can_header(xml_header)
......@@ -375,17 +378,16 @@ class IOParser(object):
## Parse CANBUS Header
# @param self object pointer
# @param xml SpaceWire Header xml node
def parse_can_header(selfself, xml):
def parse_can_header(self, xml):
# clear previous errors and warning
self.logger.clear_errors(3)
# parse attributes
header = CanbusHeader()
header = CanHeader()
header.extended = xml.parse_attr(CANHEADER_EXTENDED, VALID_BOOLEAN_TYPE, True, self.logger)
header.rtr = xml.parse_attr(CANHEADER_RTR, VALID_BOOLEAN_TYPE, True, self.logger)
header.sshot = xml.parse_attr(CANHEADER_SSHOT, VALID_BOOLEAN_TYPE, True, self.looger)
header.id = xml.parse_attr(CANHEADER_ID, VALID_ID, True, self.logger)
header.can_id = xml.parse_attr(CANHEADER_ID, VALID_ID, True, self.logger)
# sanity check
if self.logger.check_errors(): return False
......
......@@ -122,13 +122,12 @@ extern iop_port_t remote_ports[${len(iop_configuration.ports)}];
}\
</%def>
</%def name="CANHeader(header)">\
<%def name="CanHeader(header)">\
{
.can_header = {
.extended = ${},
.rtr = ${},
.sshot = ${},
.id = ${}
.extended = ${int(header.extended)},
.rtr = ${int(header.rtr)},
.id = ${header.can_id}
}
}\
</%def>
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ARINC_653_Module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ModuleName="iop_example">
<!-- Partition 3 -->
<Partition PartitionIdentifier="3" PartitionName="iop"
<!-- Partition 2 -->
<Partition PartitionIdentifier="2" PartitionName="iop"
Criticality="LEVEL_A" EntryPoint="empty" SystemPartition="false">
<Sampling_Port Name="dsampling"
Direction="DESTINATION" MaxMessageSize="1024" RefreshRateSeconds="1.0"/>
<Sampling_Port Name="iop_sender"
Direction="SOURCE" MaxMessageSize="8" RefreshRateSeconds="1.0"/>
<Sampling_Port Name="iop_receiver"
Direction="DESTINATION" MaxMessageSize="8" RefreshRateSeconds="1.0"/>
<PartitionConfiguration Personality="RTEMS" IOP="iop.xml" Cores="1">
<Libs>LIBXKY; LIBIOP; LIBPRINTF</Libs>
<Devices></Devices>
......@@ -18,10 +20,12 @@
</Partition>
<!-- Partition 1 -->
<Partition PartitionIdentifier="1" PartitionName="sampling"
<Partition PartitionIdentifier="1" PartitionName="partition1"
Criticality="LEVEL_A" EntryPoint="entry_func" SystemPartition="false">
<Sampling_Port Name="ssampling"
Direction="SOURCE" MaxMessageSize="1024" RefreshRateSeconds="1.0"/>
<Sampling_Port Name="partition_receiver"
Direction="DESTINATION" MaxMessageSize="8" RefreshRateSeconds="1.0"/>
<Sampling_Port Name="partition_sender"
Direction="SOURCE" MaxMessageSize="8" RefreshRateSeconds="1.0"/>
<PartitionConfiguration Personality="RTEMS" Cores="1">
<Libs>LIBXKY; IMASPEX; LIBPRINTF</Libs>
<Devices></Devices>
......@@ -33,49 +37,44 @@
</PartitionConfiguration>
</Partition>
<!-- Partition 2
<Partition PartitionIdentifier="2" PartitionName="queuing"
Criticality="LEVEL_A" EntryPoint="entry_func" SystemPartition="false">
<PartitionConfiguration Personality="RTEMS" Cores="1">
<Libs>LIBXKY; IMASPEX; LIBPRINTF</Libs>
<Devices></Devices>
<Cache>
CODE; DATA
</Cache>
<Memory Size="0x400000" />
<Permissions>
CACHE_CONTROL; GLOBAL_TIME; SET_TOD; SET_PARTITION_MODE;
</Permissions>
</PartitionConfiguration>
</Partition>-->
<!-- Schedule 1 -->
<Module_Schedule ScheduleIdentifier="1" ScheduleName="schedule"
InitialModuleSchedule="true" MajorFrameSeconds="1.0">
<Partition_Schedule PartitionIdentifier="1" PartitionName="sampling"
PeriodDurationSeconds="0.2" PeriodSeconds="1.0">
<Partition_Schedule PartitionIdentifier="1" PartitionName="partition1"
PeriodDurationSeconds="0.5" PeriodSeconds="1.0">
<Window_Schedule WindowIdentifier="1" PartitionPeriodStart="true"
WindowDurationSeconds="0.2" WindowStartSeconds="0.0"/>
WindowDurationSeconds="0.5" WindowStartSeconds="0.0"/>
</Partition_Schedule>
<Partition_Schedule PartitionIdentifier="3" PartitionName="iop"
PeriodDurationSeconds="0.6" PeriodSeconds="1.0">
<Partition_Schedule PartitionIdentifier="2" PartitionName="iop"
PeriodDurationSeconds="0.5" PeriodSeconds="1.0">
<Window_Schedule WindowIdentifier="3" PartitionPeriodStart="true"
WindowDurationSeconds="0.6" WindowStartSeconds="0.4"/>
WindowDurationSeconds="0.5" WindowStartSeconds="0.5"/>
</Partition_Schedule>
</Module_Schedule>
<!-- Connection table -->
<!-- Connection table -->
<Connection_Table>
<Channel ChannelIdentifier="1" ChannelName="sampling">
<Channel ChannelIdentifier="1" ChannelName="MessageIn">
<Source>
<Standard_Partition PartitionIdentifier="1" PartitionName="sampling"
PortName="ssampling"/>
<Standard_Partition PartitionIdentifier="1" PartitionName="partition1"
PortName="partition_sender"/>
</Source>
<Destination>
<Standard_Partition PartitionIdentifier="3" PartitionName="iop"
PortName="dsampling"/>
<Standard_Partition PartitionIdentifier="2" PartitionName="iop"
PortName="iop_receiver"/>
</Destination>
</Channel>
<Channel ChannelIdentifier="2" ChannelName="MessageOut">
<Source>
<Standard_Partition PartitionIdentifier="2" PartitionName="iop"
PortName="iop_sender"/>
</Source>
<Destination>
<Standard_Partition PartitionIdentifier="1" PartitionName="partition1"
PortName="partition_receiver"/>
</Destination>
</Channel>
</Connection_Table>
<!-- Module configuration -->
......
<?xml version="1.0" encoding="UTF-8"?>
<IOPartition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="iop.xsd" version="1.0" date="2013-06-05" name="iop_example" request_number="64" time_to_live="5">
<IOPartition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="iop.xsd" version="1.0" date="2017-11-20" name="iop_example" request_number="64" time_to_live="5">
<RemotePorts>
<Port Name="dsampling" LogicalDeviceId="1"/>
<Port Name="iop_receiver" LogicalDeviceId="1"/>
<Port Name="iop_sender" />
</RemotePorts>
<LogicalDevices>
<Device Id="1" Name="PARSERVER" />
</LogicalDevices>
<!--<PhysicalDevices>
<Device Id="0" Device="ETH0" Ip="192.168.0.17" MAC="d0:39:72:74:d8:1f" TXD="32" RXD="32">
<Device Id="0" Device="ETH0" Ip="192.168.0.17" MAC="00:50:C2:75:a0:60" TXD="32" RXD="32">
<LogicalRoute Id="1" LogicalDeviceId="1">
<EthHeader Ip="192.168.0.3" MAC="00:50:bf:50:07:0d" Port="13000"/>
</LogicalRoute>
</Device>
</PhysicalDevices>-->
<Device Id="1" Name="PARSERVER" Extended="1" RTR="0" />
</LogicalDevices>
<PhysicalDevices>
<Device Id="0" Device="CAN0" CanID = "2" Speed="250" TXD="32" RXD="32" InternalQueue="8" SingleMode="true" Code="f:f:f:f" Mask="f:f:f:f">
<LogicalRoute Id="1" LogicalDeviceId="1">
<CanHeader Extended="0" RTR="0" SSHOT="0" CanID="1"/>
<Device Id="1" Device="CAN0" CanID ="2" Speed="250" TXD="32" RXD="32" InternalQueue="8" SingleMode="true" Code="f:f:f:f" Mask="f:f:f:f">
<PhysicalRoute Id="1" PortId="iop_sender">
<CanHeader Extended="true" RTR="true" CanID="1"/>
</PhysicalRoute>
<LogicalRoute Id="2" LogicalDeviceId="1">
<CanHeader Extended="false" RTR="false" CanID="1"/>
</LogicalRoute>
</Device>
</PhysicalDevices>
......@@ -29,7 +24,7 @@
<ModuleSchedules>
<Schedule ScheduleIdentifier="1">
<DevicesConfiguration>
<Device DeviceId="0" Device="CAN0" Reads="5"/>
<Device DeviceId="1" Device="CAN0" Reads="5"/>
</DevicesConfiguration>
<RoutesConfiguration>
<Route RouteId="1" Active="true"/>
......
......@@ -8,7 +8,7 @@
header_compare='can_compare_header',
header_copy='can_copy_header')
%>\
<%namespace name="iop_template" file="/iop_template.mako />\
<%namespace name="iop_template" file="/iop_template.mako"/>\
/*
* ============================================================================
* This file was generated by the GMV's Configurator Tool and is part of an I/O
......@@ -22,11 +22,11 @@
#include <iop_occan.h>
#include <can_support.h>
${iop_template.RemotePortList(iop_configuration)}
${iop_template.RemotePortList(iop_configuration)}\
${iop_template.IopBuffersStorage(device.setup.txd_count + device.setup.rxd_count)}\
/**
/**
* @brief TX descriptor to IOP buffer mapping
*/
static iop_buffer_t *tx_iop_buffer[${device.setup.txd_count}];
......@@ -51,7 +51,7 @@ static CANMsg tx_msg_fifo[${device.setup.internal_queue}];
static uint8_t descriptor_table[3072];
/** @brief OCCAN control structure*/
static occan_priv occan_driver = \
static occan_priv occan_driver = ${'\\'}
{
.speed = ${device.setup.speed},
.filter = {
......@@ -74,11 +74,10 @@ static occan_priv occan_driver = \
.max = ${device.setup.internal_queue},
.fifo = tx_msg_fifo,
}
}
};
/** @brief OCCAN control strucutre */
static iop_can_device_t device_configuration =${'\\'}
static iop_can_device_t device_configuration = ${'\\'}
{
/* device configuration */
.dev = {
......@@ -89,7 +88,7 @@ static iop_can_device_t device_configuration =${'\\'}
.write = occan_write,
.close = occan_close,
},
.dev_name = ${},
}
.dev_name = "/dev/${device.alias}",
};
${iop_template.PhysicalDevice(iop_configuration, device, device_functions)}\
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