aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--data/config_multichannel_audio_kit.xml30
-rw-r--r--data/unicens.xsd573
-rw-r--r--ucs2-afb/ucs_binding.c6
-rw-r--r--ucs2-interface/ucs-xml/UcsXml.c154
-rw-r--r--ucs2-interface/ucs-xml/UcsXml.h8
-rw-r--r--ucs2-interface/ucs-xml/UcsXml_Private.c29
-rw-r--r--ucs2-interface/ucs-xml/UcsXml_Private.h2
-rw-r--r--ucs2-interface/ucs_config.h24
-rw-r--r--ucs2-interface/ucs_interface.h37
-rw-r--r--ucs2-interface/ucs_lib_interf.c45
10 files changed, 719 insertions, 189 deletions
diff --git a/data/config_multichannel_audio_kit.xml b/data/config_multichannel_audio_kit.xml
index 14da758..ad4a350 100644
--- a/data/config_multichannel_audio_kit.xml
+++ b/data/config_multichannel_audio_kit.xml
@@ -12,33 +12,6 @@
</SyncConnection>
</Node>
- <!-- 1st Microphone -->
- <Node Address="0x210">
- <StreamPort ClockConfig="64Fs" DataAlignment="Left24Bit"/>
- <SyncConnection MuteMode="NoMuting">
- <StreamSocket StreamPinID="SRXA0" Bandwidth="6"/>
- <MOSTSocket Route="Microphone1" Bandwidth="6"/>
- </SyncConnection>
- </Node>
-
- <!-- 2nd Microphone -->
- <Node Address="0x211">
- <StreamPort ClockConfig="64Fs" DataAlignment="Left24Bit"/>
- <SyncConnection MuteMode="NoMuting">
- <StreamSocket StreamPinID="SRXA0" Bandwidth="6"/>
- <MOSTSocket Route="Microphone2" Bandwidth="6"/>
- </SyncConnection>
- </Node>
-
- <!-- 3rd Microphone -->
- <Node Address="0x212">
- <StreamPort ClockConfig="64Fs" DataAlignment="Left24Bit"/>
- <SyncConnection MuteMode="NoMuting">
- <StreamSocket StreamPinID="SRXA0" Bandwidth="6"/>
- <MOSTSocket Route="Microphone3" Bandwidth="6"/>
- </SyncConnection>
- </Node>
-
<!-- 1st Slim Amplifier -->
<Node Address="0x270" Script="slim-amp-config">
<StreamPort ClockConfig="64Fs" DataAlignment="Left16Bit"/>
@@ -107,8 +80,9 @@
<Script Name="aux-io-config">
<I2CPortCreate Speed="FastMode"/>
<I2CPortWrite Mode="BurstMode" BlockCount="10" Address="0x18" Length="3" Timeout="100"
- Payload="00 0f 02 01 00 00 02 a5 df 03 3f 3f 04 02 02 10 00 00 11 00 00 12 00 00 13 00 00 14 00 00"/>
+ Payload="00 0f 02 01 00 00 02 a5 df 03 3f 3f 04 02 02 10 30 30 11 00 00 12 00 00 13 00 00 14 00 00"/>
<I2CPortWrite Mode="BurstMode" BlockCount="4" Address="0x18" Length="3" Timeout="100"
Payload="20 00 00 21 00 00 22 00 00 23 00 00"/>
+ <GPIOPortPinMode PinConfiguration="03 35 04 35 05 35 06 35 07 41 08 40"/>
</Script>
</Unicens>
diff --git a/data/unicens.xsd b/data/unicens.xsd
index 08a5ee6..1ca69bd 100644
--- a/data/unicens.xsd
+++ b/data/unicens.xsd
@@ -1,166 +1,565 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- edited with XMLSpy v2017 rel. 3 (x64) (http://www.altova.com) by Pavel Hanak (Microchip Technology Germany II GmbH & Co. KG) -->
+<!-- committed 2017-09-22 -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Unicens">
<xs:annotation>
- <xs:documentation>Schema for the description of a UNICENS configuration</xs:documentation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens</UCSElementPath>
+Schema for the description of a UNICENS configuration</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Node">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node</UCSElementPath>
+Node is a connection point that can receive, create, store or send data along distributed network routes.</xs:documentation>
+ </xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="USBPort">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/USBPort</UCSElementPath>
+Configuration Structure of a USB Port</xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute name="PhysicalLayer" type="USBPortPhysicalLayer" use="required"/>
- <xs:attribute name="DeviceInterfaces" type="HexNumber" use="required"/>
- <xs:attribute name="StreamingIfEpInCount" type="DecNumber" use="required"/>
- <xs:attribute name="StreamingIfEpOutCount" type="DecNumber" use="required"/>
+ <xs:attribute name="PhysicalLayer" type="USBPortPhysicalLayer" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/USBPort/@PhysicalLayer</UCSElementPath>
+Interface of the USB Ports Physical Layer
+This attribute corresponds with the parameter PhysicalLayer of the INIC function INIC.USBPortCreate.
+</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="DeviceInterfaces" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/USBPort/@DeviceInterfaces</UCSElementPath>
+USB Devices interfaces mask.
+This attribute corresponds with the parameter DeviceInterfaces of the INIC function INIC.USBPortCreate.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="StreamingIfEpInCount" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/USBPort/@StreamingIfEpInCount</UCSElementPath>
+IN Endpoints inside the streaming interfaces.
+This attribute corresponds with the parameter StreamingIfEpInCount of the INIC function INIC.USBPortCreate.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="StreamingIfEpOutCount" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/USBPort/@StreamingIfEpOutCount</UCSElementPath>
+OUT Endpoints inside the streaming interfaces.
+This attribute corresponds with the parameter StreamingIfEpInCount of the INIC function INIC.USBPortCreate.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="MediaLBPort">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/MediaLBPort</UCSElementPath>
+Configuration Structure of a MediaLB Port
+The MediaLB Port is the interface to the Media Local Bus.
+It supports the handling of all MOST network data types and is available in two pin-out options: MediaLB 3-Pin (single-ended) and MediaLB 6-Pin (differential). </xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute name="ClockConfig" type="MediaLBPortClockConfig" use="required"/>
+ <xs:attribute name="ClockConfig" type="MediaLBPortClockConfig" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/MediaLBPort/@ClockConfig</UCSElementPath>
+Clock speed configuration.
+This attribute corresponds with the parameter ClockConfig of the INIC function INIC.MediaLBPortCreate.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="StreamPort">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/StreamPort</UCSElementPath>
+Configuration Structure of a Stream Port</xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute name="ClockConfig" type="StreamPortClockConfig" use="required"/>
- <xs:attribute name="DataAlignment" type="StreamPortDataAlignment" use="required"/>
+ <xs:attribute name="ClockConfig" type="StreamPortClockConfig" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/StreamPort/@ClockConfig</UCSElementPath>
+Clock speed configuration.
+This attribute corresponds with the parameter ClockConfig of the INIC function INIC.StreamPortCreate.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="DataAlignment" type="StreamPortDataAlignment" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/StreamPort/@DataAlignment</UCSElementPath>
+Alignment of the data bytes .
+This attribute corresponds with the parameter DataAlignment of the INIC function INIC.StreamPortCreate</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="SyncConnection">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/SyncConnection</UCSElementPath>
+Configuration Structure of a SyncConnection It sets the connection in Sync mode.</xs:documentation>
+ </xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="Connection">
- <xs:attribute name="MuteMode" type="SyncConnectionMuteMode" use="optional"/>
+ <xs:attribute name="MuteMode" type="SyncConnectionMuteMode" use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/SyncConnection/@MuteMode</UCSElementPath>
+Mode of operation of mute.
+This attribute corresponds with the parameter MuteMode of the INIC function INIC.SyncCreate</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="AVPConnection">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/AVPConnection</UCSElementPath>
+Configuration Structure of an AVP Connection. It sets the connection in AVP mode.</xs:documentation>
+ </xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="Connection">
- <xs:attribute name="IsocPacketSize" type="AVPConnectionIsocPacketSize" use="required"/>
+ <xs:attribute name="IsocPacketSize" type="AVPConnectionIsocPacketSize" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/AVPConnection/@IsocPacketSize</UCSElementPath>
+Size of data packets.
+This attribute corresponds with the parameter IsocPacketSize of the INIC function INIC.AVPacketizedCreate</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
- <xs:attribute name="Address" type="HexNumber" use="required"/>
- <xs:attribute name="Script" type="xs:string" use="optional"/>
+ <xs:attribute name="Address" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/@Address</UCSElementPath>
+Address of the Unicens node</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="Script" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Node/@Script</UCSElementPath>
+Script to which the node is linked.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="Name" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="Script">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script</UCSElementPath>
+A script is a structure data composed of :
+The command based on INIC FBlock-Syntax to be transmitted
+The expected result also based on INIC FBlock-Syntax.
+The amount time [in milliseconds] to pause before sending the Tx command.
+
+</xs:documentation>
+ </xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:choice maxOccurs="unbounded">
<xs:element name="GPIOPortCreate">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/GPIOPortCreate</UCSElementPath>
+Creates the GPIO port with its associated port instance identifier.</xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute name="DebounceTime" type="DecNumber" use="required"/>
+ <xs:attribute name="DebounceTime" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/GPIOPortCreate/@DebounceTime</UCSElementPath>
+The timeout for the GPIO debounce timer (in ms).
+</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="GPIOPortPinMode">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/GPIOPortPinMode</UCSElementPath>
+This function is used for GPIO pin configuration.
+To change a pin into a GPIO pin, it has to be configured via GPIOPortPinMode</xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute name="PinConfiguration" type="HexData" use="required"/>
+ <xs:attribute name="PinConfiguration" type="HexData" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/GPIOPortPinMode/@PinConfiguration</UCSElementPath>
+Defines the GPIO pin configuration and clears the trigger conditions on level-sensitive inputs and sticky inputs thereby allowing reporting of further trigger events.
+Note that trigger conditions are automatically cleared for all edge-sensitive input/output GPIO classes when the INIC.GPIOPortTriggerEvent.Status message is sent.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="GPIOPinState">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/GPIOPinState</UCSElementPath>TO DO - [State of GPIO Pin : High/Low]</xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute name="Mask" type="HexNumber" use="required"/>
- <xs:attribute name="Data" type="HexNumber" use="required"/>
+ <xs:attribute name="Mask" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/GPIOPinState/@Mask</UCSElementPath>
+TO DO - [Changing certain data elements within a data store so that the structure remains similar while the information itself is changed to protect sensitive information]</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="Data" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/GPIOPinState/@Data</UCSElementPath>
+TO DO - [Data to be given to GPIO Pin State]</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="I2CPortCreate">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/I2CPortCreate</UCSElementPath>
+This function is used to define the I2C Port working as I2C-bus master.
+The function creates the I2C Port with its associated port instance identifier.
+
+</xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute name="Speed" type="I2CPortCreateSpeed" use="required"/>
+ <xs:attribute name="Speed" type="I2CPortCreateSpeed" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/I2CPortCreate/@Speed</UCSElementPath>
+The speed grade of I2C port.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="I2CPortWrite">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/I2CPortWrite</UCSElementPath>
+This function writes a block of bytes to an I2C device at a specified I2C address.
+The function supports also a burst write mechanism for optimized transactions.
+
+</xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute name="Mode" type="I2CPortWriteMode" use="optional"/>
- <xs:attribute name="BlockCount" type="DecNumber" use="optional"/>
- <xs:attribute name="Address" type="HexNumber" use="required"/>
- <xs:attribute name="Length" type="DecNumber" use="optional"/>
- <xs:attribute name="Payload" type="HexData" use="required"/>
- <xs:attribute name="Timeout" type="DecNumber" use="optional"/>
+ <xs:attribute name="Mode" type="I2CPortWriteMode" use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/I2CPortWrite/@Mode</UCSElementPath>
+The write transfer mode.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="BlockCount" type="Number" use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/I2CPortWrite/@BlockCount</UCSElementPath>
+The number of blocks to be written to the I2C address.
+If parameter mode is not set to Burst Mode, the value of block_count has to be set to 0.
+Otherwise the valid range of this parameter goes from 1 to 30. </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="Address" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/I2CPortWrite/@Address</UCSElementPath>
+Address of the target device. Use the UCS_ADDR_LOCAL_DEV macro to target the local device.
+The following address ranges are supported:
+•[0x10 ... 0x2FF]
+•[0x500 ... 0xFEF]
+•UCS_ADDR_LOCAL_DEV </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="Length" type="Number" use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/I2CPortWrite/@Length</UCSElementPath>
+The total number of bytes to be written to the addressed I2C peripheral.
+Even if parameter mode is set to Burst Mode, the data_len shall correspond to the whole size of the burst transfer.
+That is, the data_len shall equal the size of a block times the block_count value.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="Payload" type="HexData" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/I2CPortWrite/@PayLoad</UCSElementPath>
+Payload bytes to be written on I2C</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="Timeout" type="Number" use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/I2CPortWrite/@Timeout</UCSElementPath>
+The timeout for the I2C Port write. </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="I2CPortRead">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/I2CPortRead</UCSElementPath>
+This function reads a block of bytes from an I2C device at a specified I2C address.
+The function can only be used, if the I2C Port has been configured as Master.
+If the I2C Port was configured as I2C-bus slave via the configuration string, an error message will be returned.
+</xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute name="Address" type="HexNumber" use="required"/>
- <xs:attribute name="Length" type="DecNumber" use="required"/>
- <xs:attribute name="Timeout" type="DecNumber" use="optional"/>
+ <xs:attribute name="Address" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/I2CPortRead/@Address</UCSElementPath>
+Address of the target device. Use the UCS_ADDR_LOCAL_DEV macro to target the local device.
+The following address ranges are supported:
+•[0x10 ... 0x2FF]
+•[0x500 ... 0xFEF]
+•UCS_ADDR_LOCAL_DEV </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="Length" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/I2CPortRead/@Length</UCSElementPath>
+Number of bytes to be read from the address.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="Timeout" type="Number" use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/I2CPortRead/@Timeout</UCSElementPath>
+The timeout for the I2C Port read.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="MsgSend">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/MsgSend</UCSElementPath>
+TO DO</xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute name="FBlockId" type="HexNumber" use="required"/>
- <xs:attribute name="FunctionId" type="HexNumber" use="required"/>
- <xs:attribute name="OpTypeRequest" type="HexNumber" use="required"/>
- <xs:attribute name="OpTypeResponse" type="HexNumber" use="optional"/>
- <xs:attribute name="PayloadRequest" type="HexData" use="required"/>
- <xs:attribute name="PayloadResponse" type="HexData" use="optional"/>
+ <xs:attribute name="FBlockId" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/MsgSend/@FBlockId</UCSElementPath>
+FBlockId of the config msg.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="FunctionId" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/MsgSend/@FunctionId</UCSElementPath>
+TO DO</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="OpTypeRequest" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/MsgSend/@OpTypeRequest</UCSElementPath>
+TO DO</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="OpTypeResponse" type="Number" use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/MsgSend/@OpTypeResponse</UCSElementPath>
+TO DO</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="PayloadRequest" type="HexData" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/MsgSend/@PayloadRequest</UCSElementPath>
+TO DO</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="PayloadResponse" type="HexData" use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/MsgSend/@PayloadResponse</UCSElementPath>
+TO DO</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="Pause">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/Pause</UCSElementPath>
+Specifies the pause which shall be set before sending the configuration message.</xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute name="WaitTime" type="DecNumber" use="required"/>
+ <xs:attribute name="WaitTime" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/Pause/@WaitTime</UCSElementPath>
+TO DO -[Time for which pause is to be done]</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
- <xs:attribute name="Name" type="xs:string" use="required"/>
+ <xs:attribute name="Name" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Script/@Name</UCSElementPath>
+Name of the Script</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
- <xs:attribute name="AsyncBandwidth" type="DecNumber" use="required"/>
+ <xs:attribute name="AsyncBandwidth" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/@AsyncBandwidth</UCSElementPath>
+Asynchronous bandwidth of the Unicens network.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
<xs:complexType name="Connection">
<xs:choice minOccurs="2" maxOccurs="2">
- <xs:element name="MOSTSocket" type="MOSTSocketType"/>
+ <xs:element name="MOSTSocket" type="MOSTSocketType">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/MOSTSocket</UCSElementPath>
+Configuration Structure of a MOST Socket</xs:documentation>
+ </xs:annotation>
+ </xs:element>
<xs:element name="USBSocket">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/USBSocket</UCSElementPath>
+Configuration Structure of a USB Socket.</xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute name="EndpointAddress" type="HexNumber" use="required"/>
- <xs:attribute name="FramesPerTransaction" type="DecNumber" use="required"/>
+ <xs:attribute name="EndpointAddress" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/USBSocket/@EndpointAddress</UCSElementPath>
+Address of a USB Endpoint.
+This attribute corresponds with the parameter EndpointAddress of the INIC function INIC.USBSocketCreate</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="FramesPerTransaction" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/USBSocket/@FramesPerTransaction</UCSElementPath>
+ FramesPerTransaction defines the number of data frames that are transferred within one USB bulk transaction.The value depends on the data type being used.
+ The MOST network frame is six times shorter than the duration of one USB Microframe, the minimum number of FramesPerTransaction must be 7.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="MediaLBSocket">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/MediaLBSocket</UCSElementPath>
+Configuration Structure of MediaLB Socket</xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute name="ChannelAddress" type="HexNumber" use="required"/>
- <xs:attribute name="Bandwidth" type="xs:integer" use="required"/>
+ <xs:attribute name="ChannelAddress" type="Number" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/MediaLBSocket/@ChannelAddress</UCSElementPath>
+MLB Channel address.
+This attribute corresponds with the parameter ChannelAddress of the INIC function INIC.MediaLBSocketCreate.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="Bandwidth" type="xs:integer" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/MediaLBSocket/@Bandwidth</UCSElementPath>
+Required socket bandwidth in bytes.
+This attribute corresponds with the parameter Bandwidth of the INIC function INIC.StreamSocketCreate.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="StreamSocket">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/StreamSocket</UCSElementPath>
+Configuration Structure of a streaming data Socket</xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute name="StreamPinID" type="StreamSocketStreamPinID" use="required"/>
- <xs:attribute name="Bandwidth" type="xs:integer" use="required"/>
+ <xs:attribute name="StreamPinID" type="StreamSocketStreamPinID" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/StreamSocket/@StreamPinID</UCSElementPath>
+ID of the serial interface pin.
+This attribute corresponds with the parameter StreamPinID of the INIC function INIC.StreamSocketCreate.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="Bandwidth" type="xs:integer" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/StreamSocket/@Bandwidth</UCSElementPath>
+Required socket bandwidth in bytes.
+This attribute corresponds with the parameter Bandwidth of the INIC function INIC.StreamSocketCreate.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
- <xs:element name="Splitter" type="SplitterCombinerType"/>
- <xs:element name="Combiner" type="SplitterCombinerType"/>
+ <xs:element name="Splitter" type="SplitterCombinerType">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Splitter</UCSElementPath>
+Configuration Structure of a splitter resource.
+A splitter enables two variants of routing to be set-up. The first variant is a splitter created with a peripheral socket.
+It enables data routing from a specified segment of the peripheral socket to a MOST socket.
+The second variant is a splitter created with a MOST socket.
+This variant enables data routing in its whole (no segments) from the MOST socket to multiple peripheral sockets.
+</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="Combiner" type="SplitterCombinerType">
+ <xs:annotation>
+ <xs:documentation>
+ <UCSElementPath>/Unicens/Combiner</UCSElementPath>
+Configuration Structure of a combiner resource.
+A combiner enables streaming data to be routed from a MOST socket to a specified segment of a peripheral socket.
+The same combiner may be used in multiple connections, which enables grouping of data streams from multiple MOST sockets into the same peripheral socket.
+</xs:documentation>
+ </xs:annotation>
+ </xs:element>
</xs:choice>
</xs:complexType>
- <xs:simpleType name="HexNumber">
+ <xs:simpleType name="Number">
<xs:annotation>
- <xs:documentation>Hexadecimal number in the format 0xd..d</xs:documentation>
+ <xs:documentation>Hexadecimal or decimal number in the format 0xd..d</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
- <xs:pattern value="0x(0|[1-9a-fA-F][0-9a-fA-F]*)"/>
+ <xs:pattern value="([0-9]+)|(0x(0|[1-9a-fA-F][0-9a-fA-F]*))"/>
</xs:restriction>
</xs:simpleType>
- <xs:simpleType name="DecNumber">
- <xs:annotation>
- <xs:documentation>Decimal number</xs:documentation>
- </xs:annotation>
- <xs:restriction base="xs:integer"/>
- </xs:simpleType>
<xs:simpleType name="USBPortPhysicalLayer">
<xs:annotation>
<xs:documentation>Physical Layer of USB port</xs:documentation>
@@ -270,21 +669,69 @@
</xs:restriction>
</xs:simpleType>
<xs:complexType name="SplitterCombinerType">
- <xs:sequence>
- <xs:element name="MOSTSocket" type="SCMOSTSocketType" maxOccurs="unbounded"/>
+ <xs:annotation>
+ <xs:documentation><UCSElementPath>/Unicens/SplitterCombinerType</UCSElementPath>TO DO</xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="MOSTSocket" type="SCMOSTSocketType" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation><UCSElementPath>/Unicens/SplitterCombinerType/MOSTSocket</UCSElementPath>TO DO - [Combination of Splitter and combiner.
+Splitter : enables two variants of routing to be set-up. The first variant is a splitter created with a peripheral socket.
+It enables data routing from a specified segment of the peripheral socket to a MOST socket. The second variant is a splitter created with a MOST socket.
+This variant enables data routing in its whole (no segments) from the MOST socket to multiple peripheral sockets.
+
+Combiner : A combiner enables streaming data to be routed from a MOST socket to a specified segment of a peripheral socket.
+The same combiner may be used in multiple connections, which enables grouping of data streams from multiple MOST sockets into the same peripheral socket ]</xs:documentation>
+ </xs:annotation>
+ </xs:element>
</xs:sequence>
- <xs:attribute name="BytesPerFrame" type="xs:integer" use="required"/>
+ <xs:attribute name="BytesPerFrame" type="xs:integer" use="required">
+ <xs:annotation>
+ <xs:documentation><UCSElementPath>/Unicens/SplitterCombinerType/@BytesPerFrame</UCSElementPath>
+Total number of data bytes to be transferred each MOST network frame.
+</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
<xs:complexType name="MOSTSocketType">
- <xs:attribute name="Route" type="xs:string" use="required"/>
- <xs:attribute name="Bandwidth" type="xs:integer" use="required"/>
- <xs:attribute name="IsActive" type="xs:boolean" use="optional"/>
- <xs:attribute name="RouteId" type="HexNumber" use="optional"/>
+ <xs:annotation>
+ <xs:documentation><UCSElementPath>/Unicens/MOSTSocketType</UCSElementPath>TO DO</xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="Route" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation><UCSElementPath>/Unicens/MOSTSocketType/@Route</UCSElementPath>
+A (virtual) route is a logical unidirectional connection between two endpoints. An endpoint acts as a MOST connection in INIC plus the internal linked resources</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="Bandwidth" type="xs:integer" use="required">
+ <xs:annotation>
+ <xs:documentation><UCSElementPath>/Unicens/MOSTSocketType/@Bandwidth</UCSElementPath>TO DO - [Bandwidth of MOST Socket Type] </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="IsActive" type="xs:boolean" use="optional">
+ <xs:annotation>
+ <xs:documentation><UCSElementPath>/Unicens/MOSTSocketType/@IsActive</UCSElementPath>TO DO -[Determines the state of MOST Socket type : Active/Inactive]</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="RouteId" type="Number" use="optional">
+ <xs:annotation>
+ <xs:documentation><UCSElementPath>/Unicens/MOSTSocketType/@RouteId</UCSElementPath>
+User-defined route identifier</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
<xs:complexType name="SCMOSTSocketType">
- <xs:complexContent>
+ <xs:annotation>
+ <xs:documentation><UCSElementPath>/Unicens/SCMOSTSocketType</UCSElementPath>TO DO</xs:documentation>
+ </xs:annotation>
+ <xs:complexContent>
<xs:extension base="MOSTSocketType">
- <xs:attribute name="Offset" type="xs:integer" use="required"/>
+ <xs:attribute name="Offset" type="xs:integer" use="required">
+ <xs:annotation>
+ <xs:documentation><UCSElementPath>/Unicens/SCMOSTSocketType/@Offset</UCSElementPath>
+Offset from where the socket data should be routed from a splitter.
+</xs:documentation>
+ </xs:annotation></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
diff --git a/ucs2-afb/ucs_binding.c b/ucs2-afb/ucs_binding.c
index ee1bce6..e1451a0 100644
--- a/ucs2-afb/ucs_binding.c
+++ b/ucs2-afb/ucs_binding.c
@@ -107,6 +107,10 @@ STATIC int onTimerCB (sd_event_source* source,uint64_t timer, void* pTag) {
return 0;
}
+void UCSI_CB_OnNetworkState(void *pTag, bool isAvailable, uint16_t packetBandwidth, uint8_t amountOfNodes)
+{
+}
+
/* UCS2 Interface Timer Callback */
PUBLIC void UCSI_CB_OnSetServiceTimer(void *pTag, uint16_t timeout) {
uint64_t usec;
@@ -197,7 +201,7 @@ void UCSI_CB_OnAmsMessageReceived(void *pTag)
Don't forget to call UCSI_ReleaseAmsMessage after that */
}
-void UCSI_CB_OnRouteResult(void *pTag, uint16_t routeId, bool isActive)
+void UCSI_CB_OnRouteResult(void *pTag, uint16_t routeId, bool isActive, uint16_t connectionLabel)
{
}
diff --git a/ucs2-interface/ucs-xml/UcsXml.c b/ucs2-interface/ucs-xml/UcsXml.c
index 8837356..4c392cd 100644
--- a/ucs2-interface/ucs-xml/UcsXml.c
+++ b/ucs2-interface/ucs-xml/UcsXml.c
@@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------------------------*/
-/* Unicens XML Parser */
+/* UNICENS XML Parser */
/* Copyright 2017, Microchip Technology Inc. and its subsidiaries. */
/* */
/* Redistribution and use in source and binary forms, with or without */
@@ -38,7 +38,7 @@
/************************************************************************/
#define COMPILETIME_CHECK(cond) (void)sizeof(int[2 * !!(cond) - 1])
-#define RETURN_ASSERT(result) { assert(false); return result; }
+#define RETURN_ASSERT(result) { UcsXml_CB_OnError("Assertion in file=%s, line=%d", 2, __FILE__, __LINE__); return result; }
#define MISC_HB(value) ((uint8_t)((uint16_t)(value) >> 8))
#define MISC_LB(value) ((uint8_t)((uint16_t)(value) & (uint16_t)0xFF))
@@ -54,6 +54,7 @@ struct UcsXmlRoute
struct UcsXmlScript
{
+ bool inUse;
char scriptName[32];
Ucs_Rm_Node_t *node;
struct UcsXmlScript *next;
@@ -169,7 +170,7 @@ static const char* ALL_SOCKETS[] = { MOST_SOCKET, USB_SOCKET, MLB_SOCKET,
#define MLB_PORT "MediaLBPort"
#define USB_PORT "USBPort"
#define STRM_PORT "StreamPort"
-static const char* ALL_PORTS[] = { MLB_PORT, USB_PORT, STRM_PORT };
+static const char* ALL_PORTS[] = { MLB_PORT, USB_PORT, STRM_PORT, NULL };
static const char* PHYSICAL_LAYER = "PhysicalLayer";
static const char* DEVICE_INTERFACES = "DeviceInterfaces";
@@ -231,6 +232,7 @@ static bool GetElementArray(mxml_node_t *element, const char *array[], const cha
static bool GetCount(mxml_node_t *element, const char *name, uint32_t *out, bool mandatory);
static bool GetCountArray(mxml_node_t *element, const char *array[], uint32_t *out, bool mandatory);
static bool GetString(mxml_node_t *element, const char *key, const char **out, bool mandatory);
+static bool CheckInteger(const char *val, bool forceHex);
static bool GetUInt16(mxml_node_t *element, const char *key, uint16_t *out, bool mandatory);
static bool GetUInt8(mxml_node_t *element, const char *key, uint8_t *out, bool mandatory);
static bool GetSocketType(const char *txt, MSocketType_t *out);
@@ -278,9 +280,9 @@ UcsXmlVal_t *UcsXml_Parse(const char *xmlString)
return val;
ERROR:
if (Parse_MemoryError == result)
- UcsXml_CB_OnError("XML error, aborting..", 0);
+ UcsXml_CB_OnError("XML memory error, aborting..", 0);
else
- UcsXml_CB_OnError("Allocation error, aborting..", 0);
+ UcsXml_CB_OnError("XML parsing error, aborting..", 0);
assert(false);
if (!tree)
mxmlDelete(tree);
@@ -418,19 +420,70 @@ static bool GetString(mxml_node_t *element, const char *key, const char **out, b
return false;
}
+static bool CheckInteger(const char *value, bool forceHex)
+{
+ bool hex = forceHex;
+ int32_t len;
+ if (!value) return false;
+ len = strlen(value);
+ if (len >= 3 && '0' == value[0] && 'x' == value[1])
+ {
+ hex = true;
+ value += 2;
+ }
+ while(value[0])
+ {
+ bool valid = false;
+ uint8_t v = value[0];
+ if (v >= '0' && v <= '9') valid = true;
+ if (hex)
+ {
+ if (v >= 'a' && v <= 'f') valid = true;
+ if (v >= 'A' && v <= 'F') valid = true;
+ }
+ if (!valid) return false;
+ ++value;
+ }
+ return true;
+}
+
static bool GetUInt16(mxml_node_t *element, const char *key, uint16_t *out, bool mandatory)
{
+ long int value;
const char* txt;
if (!GetString(element, key, &txt, mandatory)) return false;
- *out = strtol( txt, NULL, 0 );
+ if (!CheckInteger(txt, false))
+ {
+ UcsXml_CB_OnError("key='%s' contained invalid integer='%s'", 2, key, txt);
+ return false;
+ }
+ value = strtol( txt, NULL, 0 );
+ if (value > 0xFFFF)
+ {
+ UcsXml_CB_OnError("key='%s' is out of range='%d'", 2, key, value);
+ return false;
+ }
+ *out = value;
return true;
}
static bool GetUInt8(mxml_node_t *element, const char *key, uint8_t *out, bool mandatory)
{
+ long int value;
const char* txt;
if (!GetString(element, key, &txt, mandatory)) return false;
- *out = strtol( txt, NULL, 0 );
+ if (!CheckInteger(txt, false))
+ {
+ UcsXml_CB_OnError("key='%s' contained invalid integer='%s'", 2, key, txt);
+ return false;
+ }
+ value = strtol( txt, NULL, 0 );
+ if (value > 0xFF)
+ {
+ UcsXml_CB_OnError("key='%s' is out of range='%d'", 2, key, value);
+ return false;
+ }
+ *out = value;
return true;
}
@@ -508,6 +561,13 @@ static bool GetPayload(mxml_node_t *element, const char *name, uint8_t **pPayloa
assert(false);
return 0;
}
+ if (!CheckInteger(token, true))
+ {
+ UcsXml_CB_OnError("Script payload contains non valid hex number='%s'", 1, token);
+ free(txtCopy);
+ assert(false);
+ return 0;
+ }
p[offset + len++] = strtol( token, NULL, 16 );
token = strtok_r( NULL, " ,.-", &tkPtr );
}
@@ -650,29 +710,30 @@ static ParseResult_t ParseAll(mxml_node_t *tree, UcsXmlVal_t *ucs, PrivateData_t
if (Parse_Success != (result = ParseNode(sub, priv)))
return result;
/*/Iterate all connections. Node without any connection is also valid.*/
- if (!GetElementArray(sub->child, ALL_CONNECTIONS, &conType, &con))
- continue;
- while(con)
+ if (GetElementArray(sub->child, ALL_CONNECTIONS, &conType, &con))
{
- const char *socTypeStr;
- MSocketType_t socType;
- mxml_node_t *soc;
- memset(&priv->conData, 0, sizeof(ConnectionData_t));
- if (Parse_Success != (result = ParseConnection(con, conType, priv)))
- return result;
- /*Iterate all sockets*/
- if(!GetElementArray(con->child, ALL_SOCKETS, &socTypeStr, &soc)) RETURN_ASSERT(Parse_XmlError);
- while(soc)
+ while(con)
{
- if (!GetSocketType(socTypeStr, &socType)) RETURN_ASSERT(Parse_XmlError);
- if (Parse_Success != (result = ParseSocket(soc, (0 == priv->conData.sockCnt), socType, &priv->conData.jobList, priv)))
+ const char *socTypeStr;
+ MSocketType_t socType;
+ mxml_node_t *soc;
+ memset(&priv->conData, 0, sizeof(ConnectionData_t));
+ if (Parse_Success != (result = ParseConnection(con, conType, priv)))
return result;
- ++priv->conData.sockCnt;
- if(!GetElementArray(soc, ALL_SOCKETS, &socTypeStr, &soc))
+ /*Iterate all sockets*/
+ if(!GetElementArray(con->child, ALL_SOCKETS, &socTypeStr, &soc)) RETURN_ASSERT(Parse_XmlError);
+ while(soc)
+ {
+ if (!GetSocketType(socTypeStr, &socType)) RETURN_ASSERT(Parse_XmlError);
+ if (Parse_Success != (result = ParseSocket(soc, (0 == priv->conData.sockCnt), socType, &priv->conData.jobList, priv)))
+ return result;
+ ++priv->conData.sockCnt;
+ if(!GetElementArray(soc, ALL_SOCKETS, &socTypeStr, &soc))
+ break;
+ }
+ if(!GetElementArray(con, ALL_CONNECTIONS, &conType, &con))
break;
}
- if(!GetElementArray(con, ALL_CONNECTIONS, &conType, &con))
- break;
}
++ucs->nodSize;
if (!GetElement(sub, NODE, false, &sub, false))
@@ -687,6 +748,8 @@ static ParseResult_t ParseAll(mxml_node_t *tree, UcsXmlVal_t *ucs, PrivateData_t
/*Iterate all scripts. No scripts at all is allowed*/
if(GetElement(tree, SCRIPT, true, &sub, false))
{
+ bool found = true;
+ struct UcsXmlScript *scrlist = priv->pScrLst;
while(sub)
{
result = ParseScript(sub, priv);
@@ -695,6 +758,18 @@ static ParseResult_t ParseAll(mxml_node_t *tree, UcsXmlVal_t *ucs, PrivateData_t
if(!GetElement(sub, SCRIPT, false, &sub, false))
break;
}
+ /* Check if all scripts where referenced */
+ while(NULL != scrlist)
+ {
+ if (!scrlist->inUse)
+ {
+ UcsXml_CB_OnError("Script not defined:'%s', used by node=0x%X", 1, scrlist->scriptName, scrlist->node->signature_ptr->node_address);
+ found = false;
+ }
+ scrlist = scrlist->next;
+ }
+ if (!found)
+ RETURN_ASSERT(Parse_XmlError);
}
return result;
}
@@ -756,7 +831,7 @@ static ParseResult_t ParseNode(mxml_node_t *node, PrivateData_t *priv)
UcsXml_CB_OnError("Unknown Port:'%s'", 1, txt);
RETURN_ASSERT(Parse_XmlError);
}
- if(!GetElementArray(port, ALL_SOCKETS, &txt, &port))
+ if(!GetElementArray(port, ALL_PORTS, &txt, &port))
break;
}
}
@@ -995,6 +1070,7 @@ static ParseResult_t ParseSocket(mxml_node_t *soc, bool isSource, MSocketType_t
/*Connect in and out socket once they are created*/
if (priv->conData.inSocket && priv->conData.outSocket)
{
+ bool mostIsInput;
bool mostIsOutput;
Ucs_Rm_EndPoint_t *ep;
struct UcsXmlRoute *route;
@@ -1031,7 +1107,13 @@ static ParseResult_t ParseSocket(mxml_node_t *soc, bool isSource, MSocketType_t
ep = MCalloc(&priv->objList, 1, sizeof(Ucs_Rm_EndPoint_t));
if (NULL == ep) RETURN_ASSERT(Parse_MemoryError);
+ mostIsInput = (UCS_XRM_RC_TYPE_MOST_SOCKET == *((Ucs_Xrm_ResourceType_t *)priv->conData.inSocket));
mostIsOutput = (UCS_XRM_RC_TYPE_MOST_SOCKET == *((Ucs_Xrm_ResourceType_t *)priv->conData.outSocket));
+ if (!mostIsInput && !mostIsOutput)
+ {
+ UcsXml_CB_OnError("At least one MOST socket required per connection", 0);
+ RETURN_ASSERT(Parse_XmlError);
+ }
ep->endpoint_type = mostIsOutput ? UCS_RM_EP_SOURCE : UCS_RM_EP_SINK;
ep->jobs_list_ptr = GetJobList(*jobList, &priv->objList);
if(NULL == ep->jobs_list_ptr) RETURN_ASSERT(Parse_MemoryError);
@@ -1102,7 +1184,7 @@ static ParseResult_t ParseScript(mxml_node_t *scr, PrivateData_t *priv)
if (Parse_Success != result) return result;
} else {
UcsXml_CB_OnError("Unknown script action:'%s'", 1, txt);
- /*RETURN_ASSERT(Parse_XmlError);*/
+ RETURN_ASSERT(Parse_XmlError);
}
if (!GetElementArray(act, ALL_SCRIPTS, &txt, &act))
break;
@@ -1117,6 +1199,7 @@ static ParseResult_t ParseScript(mxml_node_t *scr, PrivateData_t *priv)
Ucs_Rm_Node_t *node = scrlist->node;
node->script_list_ptr = script;
node->script_list_size = actCnt;
+ scrlist->inUse = true;
found = true;
}
scrlist = scrlist->next;
@@ -1277,7 +1360,11 @@ static ParseResult_t ParseScriptPortCreate(mxml_node_t *act, Ucs_Ns_Script_t *sc
speed = 0;
else if (0 == strcmp(txt, I2C_SPEED_FAST))
speed = 1;
- else RETURN_ASSERT(Parse_XmlError);
+ else
+ {
+ UcsXml_CB_OnError("Invalid I2C speed:'%s'", 1, txt);
+ RETURN_ASSERT(Parse_XmlError);
+ }
req = scr->send_cmd;
res = scr->exp_result;
req->InstId = res->InstId = 1;
@@ -1317,6 +1404,11 @@ static ParseResult_t ParseScriptPortWrite(mxml_node_t *act, Ucs_Ns_Script_t *scr
mode = 1;
else if (0 == strcmp(txt, I2C_WRITE_MODE_BURST))
mode = 2;
+ else
+ {
+ UcsXml_CB_OnError("Invalid I2C mode:'%s'", 1, txt);
+ RETURN_ASSERT(Parse_XmlError);
+ }
} else {
mode = 0;
}
@@ -1458,7 +1550,11 @@ static ParseResult_t ParseRoutes(UcsXmlVal_t *ucs, PrivateData_t *priv)
}
sourceRoute = sourceRoute->next;
}
- assert(routeAmount == ucs->routesSize);
+ if (routeAmount != ucs->routesSize)
+ {
+ UcsXml_CB_OnError("At least one sink (num=%d) is not connected, because of wrong Route name!", 2, (routeAmount - ucs->routesSize));
+ RETURN_ASSERT(Parse_XmlError);
+ }
#ifdef DEBUG
/* Third perform checks when running in debug mode*/
diff --git a/ucs2-interface/ucs-xml/UcsXml.h b/ucs2-interface/ucs-xml/UcsXml.h
index b36e007..8aff893 100644
--- a/ucs2-interface/ucs-xml/UcsXml.h
+++ b/ucs2-interface/ucs-xml/UcsXml.h
@@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------------------------*/
-/* Unicens XML Parser */
+/* UNICENS XML Parser */
/* Copyright 2017, Microchip Technology Inc. and its subsidiaries. */
/* */
/* Redistribution and use in source and binary forms, with or without */
@@ -38,7 +38,7 @@ extern "C" {
#include <stdint.h>
#include "ucs_api.h"
-/** Structure holding informations to startup Unicens (UCS).
+/** Structure holding informations to startup UNICENS (UCS).
* Pass all these variables to the UCS manager structure, but not pInternal.
* */
typedef struct
@@ -62,8 +62,8 @@ typedef struct
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/**
- * \brief Initializes Unicens XML parser module, parses the given string and
- * generate the data needed to run Unicens (UCS) library.
+ * \brief Initializes UNICENS XML parser module, parses the given string and
+ * generate the data needed to run UNICENS (UCS) library.
*
* \note In case of errors the callback UcsXml_CB_OnError will be raised.
* \param xmlString - Zero terminated XML string. The string will not be used
diff --git a/ucs2-interface/ucs-xml/UcsXml_Private.c b/ucs2-interface/ucs-xml/UcsXml_Private.c
index 9350191..743598f 100644
--- a/ucs2-interface/ucs-xml/UcsXml_Private.c
+++ b/ucs2-interface/ucs-xml/UcsXml_Private.c
@@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------------------------*/
-/* Unicens XML Parser */
+/* UNICENS XML Parser */
/* Copyright 2017, Microchip Technology Inc. and its subsidiaries. */
/* */
/* Redistribution and use in source and binary forms, with or without */
@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
+#include "UcsXml.h"
#include "UcsXml_Private.h"
static const char* USB_PHY_STANDARD = "Standard";
@@ -69,8 +70,8 @@ static const char* VAL_TRUE = "true";
static const char* VAL_FALSE = "false";
*/
-#define ASSERT_FALSE() { assert(false); return false; }
-#define CHECK_POINTER(PTR) if (NULL == PTR) { ASSERT_FALSE(); }
+#define ASSERT_FALSE(func, par) { UcsXml_CB_OnError("Parameter error in attribute=%s value=%s, file=%s, line=%d", 4, func, par, __FILE__, __LINE__); return false; }
+#define CHECK_POINTER(PTR) if (NULL == PTR) { ASSERT_FALSE(PTR, "NULL pointer"); }
static int32_t Str2Int(const char *val)
{
@@ -149,7 +150,7 @@ bool GetMostSocket(Ucs_Xrm_MostSocket_t **mostSoc, struct MostSocketParameters *
soc->data_type = UCS_MOST_SCKT_DISC_FRAME_PHASE;
break;
default:
- ASSERT_FALSE();
+ ASSERT_FALSE("GetMostSocket->dataType", "");
}
return true;
}
@@ -176,7 +177,7 @@ bool GetUsbPort(Ucs_Xrm_UsbPort_t **usbPort, struct UsbPortParameters *param)
port->physical_layer = UCS_USB_PHY_LAYER_STANDARD;
else if (0 == strcmp(USB_PHY_HSIC, param->physicalLayer))
port->physical_layer = UCS_USB_PHY_LAYER_HSCI;
- else ASSERT_FALSE();
+ else ASSERT_FALSE("GetUsbPort->physical_layer", param->physicalLayer);
return true;
}
@@ -220,7 +221,7 @@ bool GetUsbSocket(Ucs_Xrm_UsbSocket_t **usbSoc, struct UsbSocketParameters *para
soc->data_type = UCS_USB_SCKT_IPC_PACKET;
break;
default:
- ASSERT_FALSE();
+ ASSERT_FALSE("GetUsbSocket->dataType", "");
}
soc->end_point_addr = (uint8_t)Str2Int(param->endpointAddress);
soc->frames_per_transfer = (uint16_t)Str2Int(param->framesPerTrans);
@@ -256,7 +257,7 @@ bool GetMlbPort(Ucs_Xrm_MlbPort_t **mlbPort, struct MlbPortParameters *param)
port->clock_config = UCS_MLB_CLK_CFG_6144_FS;
else if (0 == strcmp(param->clockConfig, CLOCK_8192FS))
port->clock_config = UCS_MLB_CLK_CFG_8192_FS;
- else ASSERT_FALSE();
+ else ASSERT_FALSE("GetMlbPort->clockConfig", param->clockConfig);
return true;
}
@@ -306,7 +307,7 @@ bool GetMlbSocket(Ucs_Xrm_MlbSocket_t **mlbSoc, struct MlbSocketParameters *para
soc->data_type = UCS_MLB_SCKT_IPC_PACKET;
break;
default:
- ASSERT_FALSE();
+ ASSERT_FALSE("GetMlbSocket->dataType", "");
}
soc->channel_address = (uint16_t)Str2Int(param->channelAddress);
soc->mlb_port_obj_ptr = param->mlbPort;
@@ -343,7 +344,7 @@ bool GetStrmPort(Ucs_Xrm_StrmPort_t **strmPort, struct StrmPortParameters *param
port->clock_config = UCS_STREAM_PORT_CLK_CFG_512FS;
else if (0 == strcmp(param->clockConfig, CLOCK_WILDCARD))
port->clock_config = UCS_STREAM_PORT_CLK_CFG_WILD;
- else ASSERT_FALSE();
+ else ASSERT_FALSE("GetStrmPort->clockConfig", param->clockConfig);
} else {
port->clock_config = UCS_STREAM_PORT_CLK_CFG_WILD;
}
@@ -358,7 +359,7 @@ bool GetStrmPort(Ucs_Xrm_StrmPort_t **strmPort, struct StrmPortParameters *param
port->data_alignment = UCS_STREAM_PORT_ALGN_RIGHT24BIT;
else if (0 == strcmp(param->dataAlignment, STRM_ALIGN_SEQUENTIAL))
port->data_alignment = UCS_STREAM_PORT_ALGN_SEQ;
- else ASSERT_FALSE();
+ else ASSERT_FALSE("GetStrmPort->dataAlignment", param->dataAlignment);
return true;
}
@@ -382,7 +383,7 @@ bool GetStrmSocket(Ucs_Xrm_StrmSocket_t **strmSoc, struct StrmSocketParameters *
soc->data_type = UCS_STREAM_PORT_SCKT_SYNC_DATA;
break;
default:
- ASSERT_FALSE();
+ ASSERT_FALSE("GetStrmSocket->dataType", "");
}
soc->bandwidth = param->bandwidth;
if (0 == strcmp(param->streamPin, I2S_PIN_SRXA0))
@@ -409,7 +410,7 @@ bool GetStrmSocket(Ucs_Xrm_StrmSocket_t **strmSoc, struct StrmSocketParameters *
soc->stream_port_obj_ptr = param->streamPortB;
return true;
}
- else ASSERT_FALSE();
+ else ASSERT_FALSE("GetStrmSocket->streamPin", param->streamPin);
return true;
}
@@ -462,7 +463,7 @@ bool GetSyncCon(Ucs_Xrm_SyncCon_t **syncCon, struct SyncConParameters *param)
con->mute_mode = UCS_SYNC_MUTE_MODE_NO_MUTING;
else if (0 == strcmp(param->muteMode, MUTE_SIGNAL))
con->mute_mode = UCS_SYNC_MUTE_MODE_MUTE_SIGNAL;
- else ASSERT_FALSE();
+ else ASSERT_FALSE("GetSyncCon->mute_mode", param->muteMode);
if (param->optional_offset)
con->offset = (uint16_t)Str2Int(param->optional_offset);
else
@@ -501,7 +502,7 @@ bool GetAvpCon(Ucs_Xrm_AvpCon_t **avpCon, struct AvpConParameters *param)
con->isoc_packet_size = UCS_ISOC_PCKT_SIZE_206;
break;
default:
- ASSERT_FALSE();
+ ASSERT_FALSE("GetAvpCon->isoc_packet_size", "");
}
} else {
con->isoc_packet_size = UCS_ISOC_PCKT_SIZE_188;
diff --git a/ucs2-interface/ucs-xml/UcsXml_Private.h b/ucs2-interface/ucs-xml/UcsXml_Private.h
index f8df323..964a7ad 100644
--- a/ucs2-interface/ucs-xml/UcsXml_Private.h
+++ b/ucs2-interface/ucs-xml/UcsXml_Private.h
@@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------------------------*/
-/* Unicens XML Parser */
+/* UNICENS XML Parser */
/* Copyright 2017, Microchip Technology Inc. and its subsidiaries. */
/* */
/* Redistribution and use in source and binary forms, with or without */
diff --git a/ucs2-interface/ucs_config.h b/ucs2-interface/ucs_config.h
index 93bba34..0a47ae4 100644
--- a/ucs2-interface/ucs_config.h
+++ b/ucs2-interface/ucs_config.h
@@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------------------------*/
-/* Unicens Integration Helper Component */
+/* UNICENS Integration Helper Component */
/* Copyright 2017, Microchip Technology Inc. and its subsidiaries. */
/* */
/* Redistribution and use in source and binary forms, with or without */
@@ -38,7 +38,7 @@
#define ENABLE_AMS_LIB (true)
#define DEBUG_XRM
#define BOARD_PMS_TX_SIZE (72)
-#define CMD_QUEUE_LEN (6)
+#define CMD_QUEUE_LEN (40)
#define I2C_WRITE_MAX_LEN (32)
#include <string.h>
@@ -52,7 +52,7 @@
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/**
- * \brief Internal enum for Unicens Integration
+ * \brief Internal enum for UNICENS Integration
*/
typedef enum
{
@@ -73,7 +73,7 @@ typedef enum
typedef void (*Ucsi_ResultCb_t)(void *result_ptr, void *request_ptr);
/**
- * \brief Internal enum for Unicens Integration
+ * \brief Internal enum for UNICENS Integration
*/
typedef enum
{
@@ -88,7 +88,7 @@ typedef enum
} UnicensCmd_t;
/**
- * \brief Internal struct for Unicens Integration
+ * \brief Internal struct for UNICENS Integration
*/
typedef struct
{
@@ -96,7 +96,7 @@ typedef struct
} UnicensCmdInit_t;
/**
- * \brief Internal struct for Unicens Integration
+ * \brief Internal struct for UNICENS Integration
*/
typedef struct
{
@@ -105,7 +105,7 @@ typedef struct
} UnicensCmdRmSetRoute_t;
/**
- * \brief Internal struct for Unicens Integration
+ * \brief Internal struct for UNICENS Integration
*/
typedef struct
{
@@ -113,7 +113,7 @@ typedef struct
} UnicensCmdNsRun_t;
/**
- * \brief Internal struct for Unicens Integration
+ * \brief Internal struct for UNICENS Integration
*/
typedef struct
{
@@ -122,7 +122,7 @@ typedef struct
} UnicensCmdGpioCreatePort_t;
/**
- * \brief Internal struct for Unicens Integration
+ * \brief Internal struct for UNICENS Integration
*/
typedef struct
{
@@ -132,7 +132,7 @@ typedef struct
} UnicensCmdGpioWritePort_t;
/**
- * \brief Internal struct for Unicens Integration
+ * \brief Internal struct for UNICENS Integration
*/
typedef struct
{
@@ -167,7 +167,7 @@ typedef struct
} UnicensCmdEntry_t;
/**
- * \brief Internal variables for one instance of Unicens Integration
+ * \brief Internal variables for one instance of UNICENS Integration
* \note Never touch any of this fields!
*/
typedef struct {
@@ -181,7 +181,7 @@ typedef struct {
} RB_t;
/**
- * \brief Internal variables for one instance of Unicens Integration
+ * \brief Internal variables for one instance of UNICENS Integration
* \note Allocate this structure for each instance (static or malloc)
* and pass it to UCSI_Init()
* \note Never touch any of this fields!
diff --git a/ucs2-interface/ucs_interface.h b/ucs2-interface/ucs_interface.h
index 5f02851..d7a1f66 100644
--- a/ucs2-interface/ucs_interface.h
+++ b/ucs2-interface/ucs_interface.h
@@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------------------------*/
-/* Unicens Integration Helper Component */
+/* UNICENS Integration Helper Component */
/* Copyright 2017, Microchip Technology Inc. and its subsidiaries. */
/* */
/* Redistribution and use in source and binary forms, with or without */
@@ -42,7 +42,7 @@ extern "C" {
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/**
- * \brief Initializes Unicens Integration module.
+ * \brief Initializes UNICENS Integration module.
* \note Must be called before any other function of this component
*
* \param pPriv - External allocated memory area for this particular
@@ -66,7 +66,7 @@ void UCSI_Init(UCSI_Data_t *pPriv, void *pTag);
bool UCSI_NewConfig(UCSI_Data_t *pPriv, UcsXmlVal_t *ucsConfig);
/**
- * \brief Offer the received control data from LLD to Unicens
+ * \brief Offer the received control data from LLD to UNICENS
* \note Call this function only from single context (not from ISR)
* \note This function can be called repeated until it return false
*
@@ -83,7 +83,7 @@ bool UCSI_NewConfig(UCSI_Data_t *pPriv, UcsXmlVal_t *ucsConfig);
bool UCSI_ProcessRxData(UCSI_Data_t *pPriv, const uint8_t *pBuffer, uint16_t len);
/**
- * \brief Gives Unicens Integration module time to do its job
+ * \brief Gives UNICENS Integration module time to do its job
* \note Call this function only from single context (not from ISR)
*
* \param pPriv - private data section of this instance
@@ -116,7 +116,7 @@ void UCSI_Timeout(UCSI_Data_t *pPriv);
bool UCSI_SendAmsMessage(UCSI_Data_t *my, uint16_t msgId, uint16_t targetAddress, uint8_t *pPayload, uint32_t payloadLen);
/**
- * \brief Gets the queued AMS message from Unicens stack
+ * \brief Gets the queued AMS message from UNICENS stack
*
* \note Call this function only from single context (not from ISR)
* \note This function may be called cyclic or when UCSI_CB_OnAmsMessageReceived was raised
@@ -151,7 +151,7 @@ void UCSI_ReleaseAmsMessage(UCSI_Data_t *my);
* \param routeId - identifier as given in XML file along with MOST socket (unique)
* \param isActive - true, route will become active. false, route will be deallocated
*
- * \return true, if route was found and the specific command was enqueued to Unicens.
+ * \return true, if route was found and the specific command was enqueued to UNICENS.
*/
bool UCSI_SetRouteActive(UCSI_Data_t *pPriv, uint16_t routeId, bool isActive);
@@ -170,7 +170,7 @@ bool UCSI_SetRouteActive(UCSI_Data_t *pPriv, uint16_t routeId, bool isActive);
* \param result_fptr - Callback function notifying the asynchronous result.
* \param request_ptr - User reference which is provided for the asynchronous result.
*
- * \return true, if route command was enqueued to Unicens.
+ * \return true, if route command was enqueued to UNICENS.
*/
bool UCSI_I2CWrite(UCSI_Data_t *pPriv, uint16_t targetAddress, bool isBurst, uint8_t blockCount,
uint8_t slaveAddr, uint16_t timeout, uint8_t dataLen, uint8_t *pData,
@@ -185,7 +185,7 @@ bool UCSI_I2CWrite(UCSI_Data_t *pPriv, uint16_t targetAddress, bool isBurst, uin
* \param gpioPinId - INIC GPIO PIN starting with 0 for the first GPIO.
* \param isHighState - true, high state = 3,3V. false, low state = 0V.
*
- * \return true, if GPIO command was enqueued to Unicens.
+ * \return true, if GPIO command was enqueued to UNICENS.
*/
bool UCSI_SetGpioState(UCSI_Data_t *pPriv, uint16_t targetAddress, uint8_t gpioPinId, bool isHighState);
@@ -212,9 +212,18 @@ extern uint16_t UCSI_CB_OnGetTime(void *pTag);
*/
extern void UCSI_CB_OnSetServiceTimer(void *pTag, uint16_t timeout);
+/**
+ * \brief Callback when ever the state of the Network has changed.
+ * \note This function must be implemented by the integrator
+ * \param pTag - Pointer given by the integrator by UCSI_Init
+ * \param isAvailable - true, if the network is operable. false, network is down. No message or stream can be sent or received.
+ * \param packetBandwidth - The amount of bytes per frame reserved for the Ethernet channel. Must match to the given packetBw value passed to UCSI_NewConfig.
+ * \param amountOfNodes - The amount of network devices found in the ring.
+ */
+extern void UCSI_CB_OnNetworkState(void *pTag, bool isAvailable, uint16_t packetBandwidth, uint8_t amountOfNodes);
/**
- * \brief Callback when ever an Unicens forms a human readable message.
+ * \brief Callback when ever an UNICENS forms a human readable message.
* This can be error events or when enabled also debug messages.
* \note This function must be implemented by the integrator
* \param pTag - Pointer given by the integrator by UCSI_Init
@@ -225,7 +234,6 @@ extern void UCSI_CB_OnSetServiceTimer(void *pTag, uint16_t timeout);
extern void UCSI_CB_OnUserMessage(void *pTag, bool isError, const char format[],
uint16_t vargsCnt, ...);
-
/**
* \brief Callback when ever this instance needs to be serviced.
* \note Call UCSI_Service by your scheduler at the next run
@@ -235,7 +243,7 @@ extern void UCSI_CB_OnUserMessage(void *pTag, bool isError, const char format[],
extern void UCSI_CB_OnServiceRequired(void *pTag);
/**
- * \brief Callback when ever this instance of Unicens wants to send control data to the LLD.
+ * \brief Callback when ever this instance of UNICENS wants to send control data to the LLD.
* \note This function must be implemented by the integrator
* \param pTag - Pointer given by the integrator by UCSI_Init
* \param pPayload - Byte array to be sent on the INIC control channel
@@ -245,7 +253,7 @@ extern void UCSI_CB_OnTxRequest(void *pTag,
const uint8_t *pPayload, uint32_t payloadLen);
/**
- * \brief Callback when Unicens instance has been stopped.
+ * \brief Callback when UNICENS instance has been stopped.
* \note This event can be used to free memory holding the resources
* passed with UCSI_NewConfig
* \note This function must be implemented by the integrator
@@ -254,7 +262,7 @@ extern void UCSI_CB_OnTxRequest(void *pTag,
extern void UCSI_CB_OnStop(void *pTag);
/**
- * \brief Callback when Unicens instance has received an AMS message
+ * \brief Callback when UNICENS instance has received an AMS message
* \note This function must be implemented by the integrator
* \note After this callback, call UCSI_GetAmsMessage indirect by setting a flag
* \param pTag - Pointer given by the integrator by UCSI_Init
@@ -267,8 +275,9 @@ extern void UCSI_CB_OnAmsMessageReceived(void *pTag);
* \param pTag - Pointer given by the integrator by UCSI_Init
* \param routeId - identifier as given in XML file along with MOST socket (unique)
* \param isActive - true, if the route is now in use. false, the route is not established.
+ * \param connectionLabel - The connection label used on the Network. Only valid, if isActive=true
*/
-extern void UCSI_CB_OnRouteResult(void *pTag, uint16_t routeId, bool isActive);
+extern void UCSI_CB_OnRouteResult(void *pTag, uint16_t routeId, bool isActive, uint16_t connectionLabel);
/**
* \brief Callback when a INIC GPIO changes its state
diff --git a/ucs2-interface/ucs_lib_interf.c b/ucs2-interface/ucs_lib_interf.c
index ad256e3..58b49d9 100644
--- a/ucs2-interface/ucs_lib_interf.c
+++ b/ucs2-interface/ucs_lib_interf.c
@@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------------------------*/
-/* Unicens Integration Helper Component */
+/* UNICENS Integration Helper Component */
/* Copyright 2017, Microchip Technology Inc. and its subsidiaries. */
/* */
/* Redistribution and use in source and binary forms, with or without */
@@ -56,9 +56,9 @@ static void OnLldCtrlStop( void *lld_user_ptr );
static void OnLldCtrlRxMsgAvailable( void *lld_user_ptr );
static void OnLldCtrlTxTransmitC( Ucs_Lld_TxMsg_t *msg_ptr, void *lld_user_ptr );
static void OnUnicensRoutingResult(Ucs_Rm_Route_t* route_ptr, Ucs_Rm_RouteInfos_t route_infos, void *user_ptr);
-static void OnUnicensMostPortStatus(uint16_t most_port_handle,
- Ucs_Most_PortAvail_t availability, Ucs_Most_PortAvailInfo_t avail_info,
- uint16_t free_streaming_bw, void* user_ptr);
+static void OnUnicensNetworkStatus(uint16_t change_mask, uint16_t events, Ucs_Network_Availability_t availability,
+ Ucs_Network_AvailInfo_t avail_info, Ucs_Network_AvailTransCause_t avail_trans_cause, uint16_t node_address,
+ uint8_t node_position, uint8_t max_position, uint16_t packet_bw, void *user_ptr);
static void OnUnicensDebugXrmResources(Ucs_Xrm_ResourceType_t resource_type,
Ucs_Xrm_ResObject_t *resource_ptr, Ucs_Xrm_ResourceInfos_t resource_infos,
Ucs_Rm_EndPoint_t *endpoint_inst_ptr, void *user_ptr);
@@ -96,7 +96,7 @@ void UCSI_Init(UCSI_Data_t *my, void *pTag)
result = Ucs_SetDefaultConfig(&my->uniInitData);
if(UCS_RET_SUCCESS != result)
{
- UCSI_CB_OnUserMessage(my->tag, true, "Can not set default values to Unicens config (result=0x%X)", 1, result);
+ UCSI_CB_OnUserMessage(my->tag, true, "Can not set default values to UNICENS config (result=0x%X)", 1, result);
assert(false);
return;
}
@@ -111,6 +111,8 @@ void UCSI_Init(UCSI_Data_t *my, void *pTag)
my->uniInitData.general.debug_error_msg_fptr = &OnUnicensDebugErrorMsg;
my->uniInitData.ams.enabled = ENABLE_AMS_LIB;
my->uniInitData.ams.rx.message_received_fptr = &OnUcsAmsRxMsgReceived;
+ my->uniInitData.network.status.notification_mask = 0xC2;
+ my->uniInitData.network.status.cb_fptr = &OnUnicensNetworkStatus;
my->uniInitData.lld.lld_user_ptr = my;
my->uniInitData.lld.start_fptr = &OnLldCtrlStart;
@@ -119,7 +121,6 @@ void UCSI_Init(UCSI_Data_t *my, void *pTag)
my->uniInitData.lld.tx_transmit_fptr = &OnLldCtrlTxTransmitC;
my->uniInitData.rm.report_fptr = &OnUnicensRoutingResult;
- my->uniInitData.rm.xrm.most_port_status_fptr = &OnUnicensMostPortStatus;
my->uniInitData.rm.debug_resource_status_fptr = &OnUnicensDebugXrmResources;
my->uniInitData.gpio.trigger_event_status_fptr = &OnUcsGpioTriggerEventStatus;
@@ -470,7 +471,7 @@ static void OnUnicensError( Ucs_Error_t error_code, void *user_ptr )
UCSI_Data_t *my = (UCSI_Data_t *)user_ptr;
error_code = error_code;
assert(MAGIC == my->magic);
- UCSI_CB_OnUserMessage(my->tag, true, "Unicens general error, code=0x%X, restarting", 1, error_code);
+ UCSI_CB_OnUserMessage(my->tag, true, "UNICENS general error, code=0x%X, restarting", 1, error_code);
e.cmd = UnicensCmd_Init;
e.val.Init.init_ptr = &my->uniInitData;
EnqueueCommand(my, &e);
@@ -556,21 +557,20 @@ static void OnLldCtrlTxTransmitC( Ucs_Lld_TxMsg_t *msg_ptr, void *lld_user_ptr )
static void OnUnicensRoutingResult(Ucs_Rm_Route_t* route_ptr, Ucs_Rm_RouteInfos_t route_infos, void *user_ptr)
{
+ uint16_t conLabel;
UCSI_Data_t *my = (UCSI_Data_t *)user_ptr;
assert(MAGIC == my->magic);
- UCSI_CB_OnRouteResult(my->tag, route_ptr->route_id, UCS_RM_ROUTE_INFOS_BUILT == route_infos);
+ conLabel = Ucs_Rm_GetConnectionLabel(my->unicens, route_ptr);
+ UCSI_CB_OnRouteResult(my->tag, route_ptr->route_id, UCS_RM_ROUTE_INFOS_BUILT == route_infos, conLabel);
}
-static void OnUnicensMostPortStatus(uint16_t most_port_handle,
- Ucs_Most_PortAvail_t availability, Ucs_Most_PortAvailInfo_t avail_info,
- uint16_t free_streaming_bw, void* user_ptr)
+static void OnUnicensNetworkStatus(uint16_t change_mask, uint16_t events, Ucs_Network_Availability_t availability,
+ Ucs_Network_AvailInfo_t avail_info, Ucs_Network_AvailTransCause_t avail_trans_cause, uint16_t node_address,
+ uint8_t node_position, uint8_t max_position, uint16_t packet_bw, void *user_ptr)
{
- /*TODO: implement*/
- most_port_handle = most_port_handle;
- availability = availability;
- avail_info = avail_info;
- free_streaming_bw = free_streaming_bw;
- user_ptr = user_ptr;
+ UCSI_Data_t *my = (UCSI_Data_t *)user_ptr;
+ assert(MAGIC == my->magic);
+ UCSI_CB_OnNetworkState(my->tag, UCS_NW_AVAILABLE == availability, packet_bw, max_position);
}
static void OnUnicensDebugXrmResources(Ucs_Xrm_ResourceType_t resource_type,
@@ -848,10 +848,9 @@ static void OnUcsI2CWrite(uint16_t node_address, uint16_t i2c_port_handle,
UCSI_CB_OnUserMessage(my->tag, true, "Remote I2C Write to node=0x%X failed", 1, node_address);
}
-/*----------------------------------------
- * Debug Message output from Unicens stack:
- *----------------------------------------
- */
+/************************************************************************/
+/* Debug Message output from UNICENS stack: */
+/************************************************************************/
#if defined(UCS_TR_ERROR) || defined(UCS_TR_INFO)
#include <stdio.h>
#define TRACE_BUFFER_SZ 200
@@ -859,7 +858,7 @@ void App_TraceError(void *ucs_user_ptr, const char module_str[], const char entr
{
va_list argptr;
char outbuf[TRACE_BUFFER_SZ];
- void *tag;
+ void *tag = NULL;
UCSI_Data_t *my = (UCSI_Data_t *)ucs_user_ptr;
if (my)
{
@@ -876,7 +875,7 @@ void App_TraceInfo(void *ucs_user_ptr, const char module_str[], const char entry
{
va_list argptr;
char outbuf[TRACE_BUFFER_SZ];
- void *tag;
+ void *tag = NULL;
UCSI_Data_t *my = (UCSI_Data_t *)ucs_user_ptr;
if (my)
{