Merge pull request #21 from tkummermehr/EnhanceXmlParser
authortkummermehr <thorsten.kummermehr@k2l.de>
Tue, 7 Nov 2017 21:16:46 +0000 (22:16 +0100)
committerGitHub <noreply@github.com>
Tue, 7 Nov 2017 21:16:46 +0000 (22:16 +0100)
Merge with current development (UNICENSd)

data/config_multichannel_audio_kit.xml
data/unicens.xsd
ucs2-afb/ucs_binding.c
ucs2-interface/ucs-xml/UcsXml.c
ucs2-interface/ucs-xml/UcsXml.h
ucs2-interface/ucs-xml/UcsXml_Private.c
ucs2-interface/ucs-xml/UcsXml_Private.h
ucs2-interface/ucs_config.h
ucs2-interface/ucs_interface.h
ucs2-interface/ucs_lib_interf.c

index 14da758..ad4a350 100644 (file)
     </SyncConnection>\r
   </Node>\r
   \r
-  <!-- 1st Microphone -->\r
-  <Node Address="0x210">\r
-    <StreamPort ClockConfig="64Fs" DataAlignment="Left24Bit"/>\r
-    <SyncConnection MuteMode="NoMuting">\r
-      <StreamSocket StreamPinID="SRXA0" Bandwidth="6"/>\r
-      <MOSTSocket Route="Microphone1" Bandwidth="6"/>\r
-    </SyncConnection>\r
-  </Node>\r
-\r
-  <!-- 2nd Microphone -->\r
-  <Node Address="0x211">\r
-    <StreamPort ClockConfig="64Fs" DataAlignment="Left24Bit"/>\r
-    <SyncConnection MuteMode="NoMuting">\r
-      <StreamSocket StreamPinID="SRXA0" Bandwidth="6"/>\r
-      <MOSTSocket Route="Microphone2" Bandwidth="6"/>\r
-    </SyncConnection>\r
-  </Node>\r
-\r
-  <!-- 3rd Microphone -->\r
-  <Node Address="0x212">\r
-    <StreamPort ClockConfig="64Fs" DataAlignment="Left24Bit"/>\r
-    <SyncConnection MuteMode="NoMuting">\r
-      <StreamSocket StreamPinID="SRXA0" Bandwidth="6"/>\r
-      <MOSTSocket Route="Microphone3" Bandwidth="6"/>\r
-    </SyncConnection>\r
-  </Node>\r
-\r
   <!-- 1st Slim Amplifier -->\r
   <Node Address="0x270" Script="slim-amp-config">\r
     <StreamPort ClockConfig="64Fs" DataAlignment="Left16Bit"/>\r
   <Script Name="aux-io-config">\r
     <I2CPortCreate Speed="FastMode"/>\r
     <I2CPortWrite Mode="BurstMode" BlockCount="10" Address="0x18" Length="3" Timeout="100"\r
-                  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"/>\r
+                  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"/>\r
     <I2CPortWrite Mode="BurstMode" BlockCount="4" Address="0x18" Length="3" Timeout="100"\r
                   Payload="20 00 00 21 00 00 22 00 00 23 00 00"/>\r
+  <GPIOPortPinMode PinConfiguration="03 35 04 35 05 35 06 35 07 41 08 40"/>\r
   </Script>\r
 </Unicens>\r
index 08a5ee6..1ca69bd 100644 (file)
 <?xml version="1.0" encoding="UTF-8"?>\r
-<!-- edited with XMLSpy v2017 rel. 3 (x64) (http://www.altova.com) by Pavel Hanak (Microchip Technology Germany II GmbH & Co. KG) -->\r
+<!-- committed 2017-09-22 -->\r
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">\r
        <xs:element name="Unicens">\r
                <xs:annotation>\r
-                       <xs:documentation>Schema for the description of a UNICENS configuration</xs:documentation>\r
+                       <xs:documentation>\r
+                               <UCSElementPath>/Unicens</UCSElementPath>\r
+Schema for the description of a UNICENS configuration</xs:documentation>\r
                </xs:annotation>\r
                <xs:complexType>\r
                        <xs:choice maxOccurs="unbounded">\r
                                <xs:element name="Node">\r
+                                       <xs:annotation>\r
+                                               <xs:documentation>\r
+                                                       <UCSElementPath>/Unicens/Node</UCSElementPath>\r
+Node is a connection point that can receive, create, store or send data along distributed network routes.</xs:documentation>\r
+                                       </xs:annotation>\r
                                        <xs:complexType>\r
                                                <xs:sequence>\r
                                                        <xs:choice minOccurs="0" maxOccurs="unbounded">\r
                                                                <xs:element name="USBPort">\r
+                                                                       <xs:annotation>\r
+                                                                               <xs:documentation>\r
+                                                                                       <UCSElementPath>/Unicens/Node/USBPort</UCSElementPath>\r
+Configuration Structure of a USB Port</xs:documentation>\r
+                                                                       </xs:annotation>\r
                                                                        <xs:complexType>\r
-                                                                               <xs:attribute name="PhysicalLayer" type="USBPortPhysicalLayer" use="required"/>\r
-                                                                               <xs:attribute name="DeviceInterfaces" type="HexNumber" use="required"/>\r
-                                                                               <xs:attribute name="StreamingIfEpInCount" type="DecNumber" use="required"/>\r
-                                                                               <xs:attribute name="StreamingIfEpOutCount" type="DecNumber" use="required"/>\r
+                                                                               <xs:attribute name="PhysicalLayer" type="USBPortPhysicalLayer" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Node/USBPort/@PhysicalLayer</UCSElementPath>\r
+Interface of the USB Ports Physical Layer\r
+This attribute corresponds with the parameter PhysicalLayer of the INIC function INIC.USBPortCreate.\r
+</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="DeviceInterfaces" type="Number" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Node/USBPort/@DeviceInterfaces</UCSElementPath>\r
+USB Devices interfaces mask.\r
+This attribute corresponds with the parameter DeviceInterfaces of the INIC function INIC.USBPortCreate.</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="StreamingIfEpInCount" type="Number" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Node/USBPort/@StreamingIfEpInCount</UCSElementPath>\r
+IN Endpoints inside the streaming interfaces.\r
+This attribute corresponds with the parameter StreamingIfEpInCount of the INIC function INIC.USBPortCreate.</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="StreamingIfEpOutCount" type="Number" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Node/USBPort/@StreamingIfEpOutCount</UCSElementPath>\r
+OUT Endpoints inside the streaming interfaces.\r
+This attribute corresponds with the parameter StreamingIfEpInCount of the INIC function INIC.USBPortCreate.</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
                                                                        </xs:complexType>\r
                                                                </xs:element>\r
                                                                <xs:element name="MediaLBPort">\r
+                                                                       <xs:annotation>\r
+                                                                               <xs:documentation>\r
+                                                                                       <UCSElementPath>/Unicens/Node/MediaLBPort</UCSElementPath>\r
+Configuration Structure of a MediaLB Port\r
+The MediaLB Port is the interface to the Media Local Bus. \r
+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>\r
+                                                                       </xs:annotation>\r
                                                                        <xs:complexType>\r
-                                                                               <xs:attribute name="ClockConfig" type="MediaLBPortClockConfig" use="required"/>\r
+                                                                               <xs:attribute name="ClockConfig" type="MediaLBPortClockConfig" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Node/MediaLBPort/@ClockConfig</UCSElementPath>\r
+Clock speed configuration.\r
+This attribute corresponds with the parameter ClockConfig of the INIC function INIC.MediaLBPortCreate.</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
                                                                        </xs:complexType>\r
                                                                </xs:element>\r
                                                                <xs:element name="StreamPort">\r
+                                                                       <xs:annotation>\r
+                                                                               <xs:documentation>\r
+                                                                                       <UCSElementPath>/Unicens/Node/StreamPort</UCSElementPath>\r
+Configuration Structure of a Stream Port</xs:documentation>\r
+                                                                       </xs:annotation>\r
                                                                        <xs:complexType>\r
-                                                                               <xs:attribute name="ClockConfig" type="StreamPortClockConfig" use="required"/>\r
-                                                                               <xs:attribute name="DataAlignment" type="StreamPortDataAlignment" use="required"/>\r
+                                                                               <xs:attribute name="ClockConfig" type="StreamPortClockConfig" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Node/StreamPort/@ClockConfig</UCSElementPath>\r
+Clock speed configuration.\r
+This attribute corresponds with the parameter ClockConfig of the INIC function INIC.StreamPortCreate.</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="DataAlignment" type="StreamPortDataAlignment" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Node/StreamPort/@DataAlignment</UCSElementPath>\r
+Alignment of the data bytes .\r
+This attribute corresponds with the parameter DataAlignment of the INIC function INIC.StreamPortCreate</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
                                                                        </xs:complexType>\r
                                                                </xs:element>\r
                                                        </xs:choice>\r
                                                        <xs:choice minOccurs="0" maxOccurs="unbounded">\r
                                                                <xs:element name="SyncConnection">\r
+                                                                       <xs:annotation>\r
+                                                                               <xs:documentation>\r
+                                                                                       <UCSElementPath>/Unicens/Node/SyncConnection</UCSElementPath>\r
+Configuration Structure of a SyncConnection It sets the connection in Sync mode.</xs:documentation>\r
+                                                                       </xs:annotation>\r
                                                                        <xs:complexType>\r
                                                                                <xs:complexContent>\r
                                                                                        <xs:extension base="Connection">\r
-                                                                                               <xs:attribute name="MuteMode" type="SyncConnectionMuteMode" use="optional"/>\r
+                                                                                               <xs:attribute name="MuteMode" type="SyncConnectionMuteMode" use="optional">\r
+                                                                                                       <xs:annotation>\r
+                                                                                                               <xs:documentation>\r
+                                                                                                                       <UCSElementPath>/Unicens/Node/SyncConnection/@MuteMode</UCSElementPath>\r
+Mode of operation of mute.\r
+This attribute corresponds with the parameter MuteMode of the INIC function INIC.SyncCreate</xs:documentation>\r
+                                                                                                       </xs:annotation>\r
+                                                                                               </xs:attribute>\r
                                                                                        </xs:extension>\r
                                                                                </xs:complexContent>\r
                                                                        </xs:complexType>\r
                                                                </xs:element>\r
                                                                <xs:element name="AVPConnection">\r
+                                                                       <xs:annotation>\r
+                                                                               <xs:documentation>\r
+                                                                                       <UCSElementPath>/Unicens/Node/AVPConnection</UCSElementPath>\r
+Configuration Structure of an AVP Connection. It sets the connection in AVP mode.</xs:documentation>\r
+                                                                       </xs:annotation>\r
                                                                        <xs:complexType>\r
                                                                                <xs:complexContent>\r
                                                                                        <xs:extension base="Connection">\r
-                                                                                               <xs:attribute name="IsocPacketSize" type="AVPConnectionIsocPacketSize" use="required"/>\r
+                                                                                               <xs:attribute name="IsocPacketSize" type="AVPConnectionIsocPacketSize" use="required">\r
+                                                                                                       <xs:annotation>\r
+                                                                                                               <xs:documentation>\r
+                                                                                                                       <UCSElementPath>/Unicens/Node/AVPConnection/@IsocPacketSize</UCSElementPath>\r
+Size of data packets.\r
+This attribute corresponds with the parameter IsocPacketSize of the INIC function INIC.AVPacketizedCreate</xs:documentation>\r
+                                                                                                       </xs:annotation>\r
+                                                                                               </xs:attribute>\r
                                                                                        </xs:extension>\r
                                                                                </xs:complexContent>\r
                                                                        </xs:complexType>\r
                                                                </xs:element>\r
                                                        </xs:choice>\r
                                                </xs:sequence>\r
-                                               <xs:attribute name="Address" type="HexNumber" use="required"/>\r
-                                               <xs:attribute name="Script" type="xs:string" use="optional"/>\r
+                                               <xs:attribute name="Address" type="Number" use="required">\r
+                                                       <xs:annotation>\r
+                                                               <xs:documentation>\r
+                                                                       <UCSElementPath>/Unicens/Node/@Address</UCSElementPath>\r
+Address of the Unicens node</xs:documentation>\r
+                                                       </xs:annotation>\r
+                                               </xs:attribute>\r
+                                               <xs:attribute name="Script" type="xs:string" use="optional">\r
+                                                       <xs:annotation>\r
+                                                               <xs:documentation>\r
+                                                                       <UCSElementPath>/Unicens/Node/@Script</UCSElementPath>\r
+Script to which the node is linked.</xs:documentation>\r
+                                                       </xs:annotation>\r
+                                               </xs:attribute>\r
+                                               <xs:attribute name="Name" use="optional"/>\r
                                        </xs:complexType>\r
                                </xs:element>\r
                                <xs:element name="Script">\r
+                                       <xs:annotation>\r
+                                               <xs:documentation>\r
+                                                       <UCSElementPath>/Unicens/Script</UCSElementPath>\r
+A script is a structure data composed of :\r
+The command based on INIC FBlock-Syntax to be transmitted\r
+The expected result also based on INIC FBlock-Syntax.\r
+The amount time [in milliseconds] to pause before sending the Tx command.\r
+\r
+</xs:documentation>\r
+                                       </xs:annotation>\r
                                        <xs:complexType>\r
                                                <xs:sequence>\r
                                                        <xs:choice maxOccurs="unbounded">\r
                                                                <xs:element name="GPIOPortCreate">\r
+                                                                       <xs:annotation>\r
+                                                                               <xs:documentation>\r
+                                                                                       <UCSElementPath>/Unicens/Script/GPIOPortCreate</UCSElementPath>\r
+Creates the GPIO port with its associated port instance identifier.</xs:documentation>\r
+                                                                       </xs:annotation>\r
                                                                        <xs:complexType>\r
-                                                                               <xs:attribute name="DebounceTime" type="DecNumber" use="required"/>\r
+                                                                               <xs:attribute name="DebounceTime" type="Number" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/GPIOPortCreate/@DebounceTime</UCSElementPath>\r
+The timeout for the GPIO debounce timer (in ms).\r
+</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
                                                                        </xs:complexType>\r
                                                                </xs:element>\r
                                                                <xs:element name="GPIOPortPinMode">\r
+                                                                       <xs:annotation>\r
+                                                                               <xs:documentation>\r
+                                                                                       <UCSElementPath>/Unicens/Script/GPIOPortPinMode</UCSElementPath>\r
+This function is used for GPIO pin configuration.\r
+To change a pin into a GPIO pin, it has to be configured via GPIOPortPinMode</xs:documentation>\r
+                                                                       </xs:annotation>\r
                                                                        <xs:complexType>\r
-                                                                               <xs:attribute name="PinConfiguration" type="HexData" use="required"/>\r
+                                                                               <xs:attribute name="PinConfiguration" type="HexData" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/GPIOPortPinMode/@PinConfiguration</UCSElementPath>\r
+Defines the GPIO pin configuration and clears the trigger conditions on level-sensitive inputs and sticky inputs thereby allowing reporting of further trigger events.\r
+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>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
                                                                        </xs:complexType>\r
                                                                </xs:element>\r
                                                                <xs:element name="GPIOPinState">\r
+                                                                       <xs:annotation>\r
+                                                                               <xs:documentation>\r
+                                                                                       <UCSElementPath>/Unicens/Script/GPIOPinState</UCSElementPath>TO DO - [State of GPIO Pin : High/Low]</xs:documentation>\r
+                                                                       </xs:annotation>\r
                                                                        <xs:complexType>\r
-                                                                               <xs:attribute name="Mask" type="HexNumber" use="required"/>\r
-                                                                               <xs:attribute name="Data" type="HexNumber" use="required"/>\r
+                                                                               <xs:attribute name="Mask" type="Number" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/GPIOPinState/@Mask</UCSElementPath>\r
+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>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="Data" type="Number" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/GPIOPinState/@Data</UCSElementPath>  \r
+TO DO - [Data to be given to GPIO Pin State]</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
                                                                        </xs:complexType>\r
                                                                </xs:element>\r
                                                                <xs:element name="I2CPortCreate">\r
+                                                                       <xs:annotation>\r
+                                                                               <xs:documentation>\r
+                                                                                       <UCSElementPath>/Unicens/Script/I2CPortCreate</UCSElementPath>\r
+This function is used to define the I2C Port working as I2C-bus master. \r
+The function creates the I2C Port with its associated port instance identifier. \r
+\r
+</xs:documentation>\r
+                                                                       </xs:annotation>\r
                                                                        <xs:complexType>\r
-                                                                               <xs:attribute name="Speed" type="I2CPortCreateSpeed" use="required"/>\r
+                                                                               <xs:attribute name="Speed" type="I2CPortCreateSpeed" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/I2CPortCreate/@Speed</UCSElementPath>\r
+The speed grade of I2C port.</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
                                                                        </xs:complexType>\r
                                                                </xs:element>\r
                                                                <xs:element name="I2CPortWrite">\r
+                                                                       <xs:annotation>\r
+                                                                               <xs:documentation>\r
+                                                                                       <UCSElementPath>/Unicens/Script/I2CPortWrite</UCSElementPath>\r
+This function writes a block of bytes to an I2C device at a specified I2C address. \r
+The function supports also a burst write mechanism for optimized transactions.\r
+\r
+</xs:documentation>\r
+                                                                       </xs:annotation>\r
                                                                        <xs:complexType>\r
-                                                                               <xs:attribute name="Mode" type="I2CPortWriteMode" use="optional"/>\r
-                                                                               <xs:attribute name="BlockCount" type="DecNumber" use="optional"/>\r
-                                                                               <xs:attribute name="Address" type="HexNumber" use="required"/>\r
-                                                                               <xs:attribute name="Length" type="DecNumber" use="optional"/>\r
-                                                                               <xs:attribute name="Payload" type="HexData" use="required"/>\r
-                                                                               <xs:attribute name="Timeout" type="DecNumber" use="optional"/>\r
+                                                                               <xs:attribute name="Mode" type="I2CPortWriteMode" use="optional">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/I2CPortWrite/@Mode</UCSElementPath>\r
+The write transfer mode.</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="BlockCount" type="Number" use="optional">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/I2CPortWrite/@BlockCount</UCSElementPath>\r
+The number of blocks to be written to the I2C address.\r
+If parameter mode is not set to Burst Mode, the value of block_count has to be set to 0.\r
+Otherwise the valid range of this parameter goes from 1 to 30. </xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="Address" type="Number" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/I2CPortWrite/@Address</UCSElementPath>\r
+Address of the target device. Use the UCS_ADDR_LOCAL_DEV macro to target the local device. \r
+The following address ranges are supported:\r
+â\80¢[0x10 ... 0x2FF]\r
+â\80¢[0x500 ... 0xFEF]\r
+â\80¢UCS_ADDR_LOCAL_DEV </xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="Length" type="Number" use="optional">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/I2CPortWrite/@Length</UCSElementPath>\r
+The total number of bytes to be written to the addressed I2C peripheral. \r
+Even if parameter mode is set to Burst Mode, the data_len shall correspond to the whole size of the burst transfer.\r
+That is, the data_len shall equal the size of a block times the block_count value.</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="Payload" type="HexData" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/I2CPortWrite/@PayLoad</UCSElementPath>\r
+Payload bytes to be written on I2C</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="Timeout" type="Number" use="optional">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/I2CPortWrite/@Timeout</UCSElementPath>\r
+The timeout for the I2C Port write. </xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
                                                                        </xs:complexType>\r
                                                                </xs:element>\r
                                                                <xs:element name="I2CPortRead">\r
+                                                                       <xs:annotation>\r
+                                                                               <xs:documentation>\r
+                                                                                       <UCSElementPath>/Unicens/Script/I2CPortRead</UCSElementPath>\r
+This function reads a block of bytes from an I2C device at a specified I2C address.\r
+The function can only be used, if the I2C Port has been configured as Master. \r
+If the I2C Port was configured as I2C-bus slave via the configuration string, an error message will be returned.  \r
+</xs:documentation>\r
+                                                                       </xs:annotation>\r
                                                                        <xs:complexType>\r
-                                                                               <xs:attribute name="Address" type="HexNumber" use="required"/>\r
-                                                                               <xs:attribute name="Length" type="DecNumber" use="required"/>\r
-                                                                               <xs:attribute name="Timeout" type="DecNumber" use="optional"/>\r
+                                                                               <xs:attribute name="Address" type="Number" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/I2CPortRead/@Address</UCSElementPath>\r
+Address of the target device. Use the UCS_ADDR_LOCAL_DEV macro to target the local device. \r
+The following address ranges are supported:\r
+â\80¢[0x10 ... 0x2FF]\r
+â\80¢[0x500 ... 0xFEF]\r
+â\80¢UCS_ADDR_LOCAL_DEV </xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="Length" type="Number" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/I2CPortRead/@Length</UCSElementPath>\r
+Number of bytes to be read from the address.</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="Timeout" type="Number" use="optional">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/I2CPortRead/@Timeout</UCSElementPath>\r
+The timeout for the I2C Port read.</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
                                                                        </xs:complexType>\r
                                                                </xs:element>\r
                                                                <xs:element name="MsgSend">\r
+                                                                       <xs:annotation>\r
+                                                                               <xs:documentation>\r
+                                                                                       <UCSElementPath>/Unicens/Script/MsgSend</UCSElementPath>\r
+TO DO</xs:documentation>\r
+                                                                       </xs:annotation>\r
                                                                        <xs:complexType>\r
-                                                                               <xs:attribute name="FBlockId" type="HexNumber" use="required"/>\r
-                                                                               <xs:attribute name="FunctionId" type="HexNumber" use="required"/>\r
-                                                                               <xs:attribute name="OpTypeRequest" type="HexNumber" use="required"/>\r
-                                                                               <xs:attribute name="OpTypeResponse" type="HexNumber" use="optional"/>\r
-                                                                               <xs:attribute name="PayloadRequest" type="HexData" use="required"/>\r
-                                                                               <xs:attribute name="PayloadResponse" type="HexData" use="optional"/>\r
+                                                                               <xs:attribute name="FBlockId" type="Number" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/MsgSend/@FBlockId</UCSElementPath>\r
+FBlockId of the config msg.</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="FunctionId" type="Number" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/MsgSend/@FunctionId</UCSElementPath>\r
+TO DO</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="OpTypeRequest" type="Number" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/MsgSend/@OpTypeRequest</UCSElementPath>\r
+TO DO</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="OpTypeResponse" type="Number" use="optional">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/MsgSend/@OpTypeResponse</UCSElementPath>\r
+TO DO</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="PayloadRequest" type="HexData" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/MsgSend/@PayloadRequest</UCSElementPath>\r
+TO DO</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
+                                                                               <xs:attribute name="PayloadResponse" type="HexData" use="optional">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/MsgSend/@PayloadResponse</UCSElementPath>\r
+TO DO</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
                                                                        </xs:complexType>\r
                                                                </xs:element>\r
                                                                <xs:element name="Pause">\r
+                                                                       <xs:annotation>\r
+                                                                               <xs:documentation>\r
+                                                                                       <UCSElementPath>/Unicens/Script/Pause</UCSElementPath>\r
+Specifies the pause which shall be set before sending the configuration message.</xs:documentation>\r
+                                                                       </xs:annotation>\r
                                                                        <xs:complexType>\r
-                                                                               <xs:attribute name="WaitTime" type="DecNumber" use="required"/>\r
+                                                                               <xs:attribute name="WaitTime" type="Number" use="required">\r
+                                                                                       <xs:annotation>\r
+                                                                                               <xs:documentation>\r
+                                                                                                       <UCSElementPath>/Unicens/Script/Pause/@WaitTime</UCSElementPath>\r
+TO DO -[Time for which pause is to be done]</xs:documentation>\r
+                                                                                       </xs:annotation>\r
+                                                                               </xs:attribute>\r
                                                                        </xs:complexType>\r
                                                                </xs:element>\r
                                                        </xs:choice>\r
                                                </xs:sequence>\r
-                                               <xs:attribute name="Name" type="xs:string" use="required"/>\r
+                                               <xs:attribute name="Name" type="xs:string" use="required">\r
+                                                       <xs:annotation>\r
+                                                               <xs:documentation>\r
+                                                                       <UCSElementPath>/Unicens/Script/@Name</UCSElementPath>\r
+Name of the Script</xs:documentation>\r
+                                                       </xs:annotation>\r
+                                               </xs:attribute>\r
                                        </xs:complexType>\r
                                </xs:element>\r
                        </xs:choice>\r
-                       <xs:attribute name="AsyncBandwidth" type="DecNumber" use="required"/>\r
+                       <xs:attribute name="AsyncBandwidth" type="Number" use="required">\r
+                               <xs:annotation>\r
+                                       <xs:documentation>\r
+                                               <UCSElementPath>/Unicens/@AsyncBandwidth</UCSElementPath>\r
+Asynchronous bandwidth of the Unicens network.</xs:documentation>\r
+                               </xs:annotation>\r
+                       </xs:attribute>\r
                </xs:complexType>\r
        </xs:element>\r
        <xs:complexType name="Connection">\r
                <xs:choice minOccurs="2" maxOccurs="2">\r
-                       <xs:element name="MOSTSocket" type="MOSTSocketType"/>\r
+                       <xs:element name="MOSTSocket" type="MOSTSocketType">\r
+                               <xs:annotation>\r
+                                       <xs:documentation>\r
+                                               <UCSElementPath>/Unicens/MOSTSocket</UCSElementPath>\r
+Configuration Structure of a MOST Socket</xs:documentation>\r
+                               </xs:annotation>\r
+                       </xs:element>\r
                        <xs:element name="USBSocket">\r
+                               <xs:annotation>\r
+                                       <xs:documentation>\r
+                                               <UCSElementPath>/Unicens/USBSocket</UCSElementPath>\r
+Configuration Structure of a USB Socket.</xs:documentation>\r
+                               </xs:annotation>\r
                                <xs:complexType>\r
-                                       <xs:attribute name="EndpointAddress" type="HexNumber" use="required"/>\r
-                                       <xs:attribute name="FramesPerTransaction" type="DecNumber" use="required"/>\r
+                                       <xs:attribute name="EndpointAddress" type="Number" use="required">\r
+                                               <xs:annotation>\r
+                                                       <xs:documentation>\r
+                                                               <UCSElementPath>/Unicens/USBSocket/@EndpointAddress</UCSElementPath>\r
+Address of a USB Endpoint.\r
+This attribute corresponds with the parameter EndpointAddress of the INIC function INIC.USBSocketCreate</xs:documentation>\r
+                                               </xs:annotation>\r
+                                       </xs:attribute>\r
+                                       <xs:attribute name="FramesPerTransaction" type="Number" use="required">\r
+                                               <xs:annotation>\r
+                                                       <xs:documentation>\r
+                                                               <UCSElementPath>/Unicens/USBSocket/@FramesPerTransaction</UCSElementPath>\r
+ FramesPerTransaction defines the number of data frames that are transferred within one USB bulk transaction.The value depends on the data type being used.\r
+ 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>\r
+                                               </xs:annotation>\r
+                                       </xs:attribute>\r
                                </xs:complexType>\r
                        </xs:element>\r
                        <xs:element name="MediaLBSocket">\r
+                               <xs:annotation>\r
+                                       <xs:documentation>\r
+                                               <UCSElementPath>/Unicens/MediaLBSocket</UCSElementPath>\r
+Configuration Structure of MediaLB Socket</xs:documentation>\r
+                               </xs:annotation>\r
                                <xs:complexType>\r
-                                       <xs:attribute name="ChannelAddress" type="HexNumber" use="required"/>\r
-                                       <xs:attribute name="Bandwidth" type="xs:integer" use="required"/>\r
+                                       <xs:attribute name="ChannelAddress" type="Number" use="required">\r
+                                               <xs:annotation>\r
+                                                       <xs:documentation>\r
+                                                               <UCSElementPath>/Unicens/MediaLBSocket/@ChannelAddress</UCSElementPath>\r
+MLB Channel address.\r
+This attribute corresponds with the parameter ChannelAddress of the INIC function INIC.MediaLBSocketCreate.</xs:documentation>\r
+                                               </xs:annotation>\r
+                                       </xs:attribute>\r
+                                       <xs:attribute name="Bandwidth" type="xs:integer" use="required">\r
+                                               <xs:annotation>\r
+                                                       <xs:documentation>\r
+                                                               <UCSElementPath>/Unicens/MediaLBSocket/@Bandwidth</UCSElementPath>\r
+Required socket bandwidth in bytes.\r
+This attribute corresponds with the parameter Bandwidth of the INIC function INIC.StreamSocketCreate.</xs:documentation>\r
+                                               </xs:annotation>\r
+                                       </xs:attribute>\r
                                </xs:complexType>\r
                        </xs:element>\r
                        <xs:element name="StreamSocket">\r
+                               <xs:annotation>\r
+                                       <xs:documentation>\r
+                                               <UCSElementPath>/Unicens/StreamSocket</UCSElementPath>\r
+Configuration Structure of a streaming data Socket</xs:documentation>\r
+                               </xs:annotation>\r
                                <xs:complexType>\r
-                                       <xs:attribute name="StreamPinID" type="StreamSocketStreamPinID" use="required"/>\r
-                                       <xs:attribute name="Bandwidth" type="xs:integer" use="required"/>\r
+                                       <xs:attribute name="StreamPinID" type="StreamSocketStreamPinID" use="required">\r
+                                               <xs:annotation>\r
+                                                       <xs:documentation>\r
+                                                               <UCSElementPath>/Unicens/StreamSocket/@StreamPinID</UCSElementPath>\r
+ID of the serial interface pin.\r
+This attribute corresponds with the parameter StreamPinID of the INIC function INIC.StreamSocketCreate.</xs:documentation>\r
+                                               </xs:annotation>\r
+                                       </xs:attribute>\r
+                                       <xs:attribute name="Bandwidth" type="xs:integer" use="required">\r
+                                               <xs:annotation>\r
+                                                       <xs:documentation>\r
+                                                               <UCSElementPath>/Unicens/StreamSocket/@Bandwidth</UCSElementPath>\r
+Required socket bandwidth in bytes.\r
+This attribute corresponds with the parameter Bandwidth of the INIC function INIC.StreamSocketCreate.</xs:documentation>\r
+                                               </xs:annotation>\r
+                                       </xs:attribute>\r
                                </xs:complexType>\r
                        </xs:element>\r
-                       <xs:element name="Splitter" type="SplitterCombinerType"/>\r
-                       <xs:element name="Combiner" type="SplitterCombinerType"/>\r
+                       <xs:element name="Splitter" type="SplitterCombinerType">\r
+                               <xs:annotation>\r
+                                       <xs:documentation>\r
+                                               <UCSElementPath>/Unicens/Splitter</UCSElementPath>\r
+Configuration Structure of a splitter resource.\r
+A splitter enables two variants of routing to be set-up. The first variant is a splitter created with a peripheral socket.\r
+It enables data routing from a specified segment of the peripheral socket to a MOST socket. \r
+The second variant is a splitter created with a MOST socket. \r
+This variant enables data routing in its whole (no segments) from the MOST socket to multiple peripheral sockets.\r
+</xs:documentation>\r
+                               </xs:annotation>\r
+                       </xs:element>\r
+                       <xs:element name="Combiner" type="SplitterCombinerType">\r
+                               <xs:annotation>\r
+                                       <xs:documentation>\r
+                                               <UCSElementPath>/Unicens/Combiner</UCSElementPath>\r
+Configuration Structure of a combiner resource.\r
+A combiner enables streaming data to be routed from a MOST socket to a specified segment of a peripheral socket. \r
+The same combiner may be used in multiple connections, which enables grouping of data streams from multiple MOST sockets into the same peripheral socket.\r
+</xs:documentation>\r
+                               </xs:annotation>\r
+                       </xs:element>\r
                </xs:choice>\r
        </xs:complexType>\r
-       <xs:simpleType name="HexNumber">\r
+       <xs:simpleType name="Number">\r
                <xs:annotation>\r
-                       <xs:documentation>Hexadecimal number in the format 0xd..d</xs:documentation>\r
+                       <xs:documentation>Hexadecimal or decimal number in the format 0xd..d</xs:documentation>\r
                </xs:annotation>\r
                <xs:restriction base="xs:string">\r
-                       <xs:pattern value="0x(0|[1-9a-fA-F][0-9a-fA-F]*)"/>\r
+                       <xs:pattern value="([0-9]+)|(0x(0|[1-9a-fA-F][0-9a-fA-F]*))"/>\r
                </xs:restriction>\r
        </xs:simpleType>\r
-       <xs:simpleType name="DecNumber">\r
-               <xs:annotation>\r
-                       <xs:documentation>Decimal number</xs:documentation>\r
-               </xs:annotation>\r
-               <xs:restriction base="xs:integer"/>\r
-       </xs:simpleType>\r
        <xs:simpleType name="USBPortPhysicalLayer">\r
                <xs:annotation>\r
                        <xs:documentation>Physical Layer of USB port</xs:documentation>\r
                </xs:restriction>\r
        </xs:simpleType>\r
        <xs:complexType name="SplitterCombinerType">\r
-               <xs:sequence>\r
-                       <xs:element name="MOSTSocket" type="SCMOSTSocketType" maxOccurs="unbounded"/>\r
+        <xs:annotation>\r
+               <xs:documentation><UCSElementPath>/Unicens/SplitterCombinerType</UCSElementPath>TO DO</xs:documentation>\r
+        </xs:annotation>\r
+        <xs:sequence>\r
+                       <xs:element name="MOSTSocket" type="SCMOSTSocketType" maxOccurs="unbounded">\r
+                               <xs:annotation>\r
+                                       <xs:documentation><UCSElementPath>/Unicens/SplitterCombinerType/MOSTSocket</UCSElementPath>TO DO - [Combination of Splitter and combiner.\r
+Splitter : enables two variants of routing to be set-up. The first variant is a splitter created with a peripheral socket.\r
+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. \r
+This variant enables data routing in its whole (no segments) from the MOST socket to multiple peripheral sockets.\r
+\r
+Combiner : A combiner enables streaming data to be routed from a MOST socket to a specified segment of a peripheral socket. \r
+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>\r
+                               </xs:annotation>\r
+                       </xs:element>\r
                </xs:sequence>\r
-               <xs:attribute name="BytesPerFrame" type="xs:integer" use="required"/>\r
+               <xs:attribute name="BytesPerFrame" type="xs:integer" use="required">\r
+                       <xs:annotation>\r
+                               <xs:documentation><UCSElementPath>/Unicens/SplitterCombinerType/@BytesPerFrame</UCSElementPath>\r
+Total number of data bytes to be transferred each MOST network frame.\r
+</xs:documentation>\r
+                       </xs:annotation>\r
+               </xs:attribute>\r
        </xs:complexType>\r
        <xs:complexType name="MOSTSocketType">\r
-               <xs:attribute name="Route" type="xs:string" use="required"/>\r
-               <xs:attribute name="Bandwidth" type="xs:integer" use="required"/>\r
-               <xs:attribute name="IsActive" type="xs:boolean" use="optional"/>\r
-               <xs:attribute name="RouteId" type="HexNumber" use="optional"/>\r
+        <xs:annotation>\r
+               <xs:documentation><UCSElementPath>/Unicens/MOSTSocketType</UCSElementPath>TO DO</xs:documentation>\r
+        </xs:annotation>\r
+        <xs:attribute name="Route" type="xs:string" use="required">\r
+                       <xs:annotation>\r
+                               <xs:documentation><UCSElementPath>/Unicens/MOSTSocketType/@Route</UCSElementPath>\r
+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>\r
+                       </xs:annotation>\r
+        </xs:attribute>\r
+               <xs:attribute name="Bandwidth" type="xs:integer" use="required">\r
+                       <xs:annotation>\r
+                               <xs:documentation><UCSElementPath>/Unicens/MOSTSocketType/@Bandwidth</UCSElementPath>TO DO - [Bandwidth of MOST Socket Type] </xs:documentation>\r
+                       </xs:annotation>\r
+               </xs:attribute>\r
+               <xs:attribute name="IsActive" type="xs:boolean" use="optional">\r
+                       <xs:annotation>\r
+                               <xs:documentation><UCSElementPath>/Unicens/MOSTSocketType/@IsActive</UCSElementPath>TO DO -[Determines the state of MOST Socket type : Active/Inactive]</xs:documentation>\r
+                       </xs:annotation>\r
+               </xs:attribute>\r
+               <xs:attribute name="RouteId" type="Number" use="optional">\r
+                       <xs:annotation>\r
+                               <xs:documentation><UCSElementPath>/Unicens/MOSTSocketType/@RouteId</UCSElementPath>\r
+User-defined route identifier</xs:documentation>\r
+                       </xs:annotation>\r
+               </xs:attribute>\r
        </xs:complexType>\r
        <xs:complexType name="SCMOSTSocketType">\r
-               <xs:complexContent>\r
+        <xs:annotation>\r
+               <xs:documentation><UCSElementPath>/Unicens/SCMOSTSocketType</UCSElementPath>TO DO</xs:documentation>\r
+        </xs:annotation>\r
+        <xs:complexContent>\r
                        <xs:extension base="MOSTSocketType">\r
-                               <xs:attribute name="Offset" type="xs:integer" use="required"/>\r
+                               <xs:attribute name="Offset" type="xs:integer" use="required">\r
+                                       <xs:annotation>\r
+                                               <xs:documentation><UCSElementPath>/Unicens/SCMOSTSocketType/@Offset</UCSElementPath>\r
+Offset from where the socket data should be routed from a splitter.\r
+</xs:documentation>\r
+                                       </xs:annotation></xs:attribute>\r
                        </xs:extension>\r
                </xs:complexContent>\r
        </xs:complexType>\r
index ee1bce6..e1451a0 100644 (file)
@@ -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)
 {
 }
 
index 8837356..4c392cd 100644 (file)
@@ -1,5 +1,5 @@
 /*------------------------------------------------------------------------------------------------*/\r
-/* Unicens XML Parser                                                                             */\r
+/* UNICENS XML Parser                                                                             */\r
 /* Copyright 2017, Microchip Technology Inc. and its subsidiaries.                                */\r
 /*                                                                                                */\r
 /* Redistribution and use in source and binary forms, with or without                             */\r
@@ -38,7 +38,7 @@
 /************************************************************************/\r
 \r
 #define COMPILETIME_CHECK(cond)  (void)sizeof(int[2 * !!(cond) - 1])\r
-#define RETURN_ASSERT(result) { assert(false); return result; }\r
+#define RETURN_ASSERT(result) { UcsXml_CB_OnError("Assertion in file=%s, line=%d", 2, __FILE__, __LINE__); return result; }\r
 #define MISC_HB(value)      ((uint8_t)((uint16_t)(value) >> 8))\r
 #define MISC_LB(value)      ((uint8_t)((uint16_t)(value) & (uint16_t)0xFF))\r
 \r
@@ -54,6 +54,7 @@ struct UcsXmlRoute
 \r
 struct UcsXmlScript\r
 {\r
+    bool inUse;\r
     char scriptName[32];\r
     Ucs_Rm_Node_t *node;\r
     struct UcsXmlScript *next;\r
@@ -169,7 +170,7 @@ static const char* ALL_SOCKETS[] = { MOST_SOCKET, USB_SOCKET, MLB_SOCKET,
 #define MLB_PORT                            "MediaLBPort"\r
 #define USB_PORT                            "USBPort"\r
 #define STRM_PORT                           "StreamPort"\r
-static const char* ALL_PORTS[] = { MLB_PORT, USB_PORT, STRM_PORT };\r
+static const char* ALL_PORTS[] = { MLB_PORT, USB_PORT, STRM_PORT, NULL };\r
 \r
 static const char* PHYSICAL_LAYER =         "PhysicalLayer";\r
 static const char* DEVICE_INTERFACES =      "DeviceInterfaces";\r
@@ -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);\r
 static bool GetCountArray(mxml_node_t *element, const char *array[], uint32_t *out, bool mandatory);\r
 static bool GetString(mxml_node_t *element, const char *key, const char **out, bool mandatory);\r
+static bool CheckInteger(const char *val, bool forceHex);\r
 static bool GetUInt16(mxml_node_t *element, const char *key, uint16_t *out, bool mandatory);\r
 static bool GetUInt8(mxml_node_t *element, const char *key, uint8_t *out, bool mandatory);\r
 static bool GetSocketType(const char *txt, MSocketType_t *out);\r
@@ -278,9 +280,9 @@ UcsXmlVal_t *UcsXml_Parse(const char *xmlString)
         return val;\r
 ERROR:\r
     if (Parse_MemoryError == result)\r
-        UcsXml_CB_OnError("XML error, aborting..", 0);\r
+        UcsXml_CB_OnError("XML memory error, aborting..", 0);\r
     else\r
-        UcsXml_CB_OnError("Allocation error, aborting..", 0);\r
+        UcsXml_CB_OnError("XML parsing error, aborting..", 0);\r
     assert(false);\r
     if (!tree)\r
         mxmlDelete(tree);\r
@@ -418,19 +420,70 @@ static bool GetString(mxml_node_t *element, const char *key, const char **out, b
     return false;\r
 }\r
 \r
+static bool CheckInteger(const char *value, bool forceHex)\r
+{\r
+    bool hex = forceHex;\r
+    int32_t len;\r
+    if (!value) return false;\r
+    len = strlen(value);\r
+    if (len >= 3 && '0' == value[0] && 'x' == value[1])\r
+    {\r
+        hex = true;\r
+        value += 2;\r
+    }\r
+    while(value[0])\r
+    {\r
+        bool valid = false;\r
+        uint8_t v = value[0];\r
+        if (v >= '0' && v <= '9') valid = true;\r
+        if (hex)\r
+        {\r
+            if (v >= 'a' && v <= 'f') valid = true;\r
+            if (v >= 'A' && v <= 'F') valid = true;\r
+        }\r
+        if (!valid) return false;\r
+        ++value;\r
+    }\r
+    return true;\r
+}\r
+\r
 static bool GetUInt16(mxml_node_t *element, const char *key, uint16_t *out, bool mandatory)\r
 {\r
+    long int value;\r
     const char* txt;\r
     if (!GetString(element, key, &txt, mandatory)) return false;\r
-    *out = strtol( txt, NULL, 0 );\r
+    if (!CheckInteger(txt, false))\r
+    {\r
+        UcsXml_CB_OnError("key='%s' contained invalid integer='%s'", 2, key, txt);\r
+        return false;\r
+    }\r
+    value = strtol( txt, NULL, 0 );\r
+    if (value > 0xFFFF)\r
+    {\r
+        UcsXml_CB_OnError("key='%s' is out of range='%d'", 2, key, value);\r
+        return false;\r
+    }\r
+    *out = value;\r
     return true;\r
 }\r
 \r
 static bool GetUInt8(mxml_node_t *element, const char *key, uint8_t *out, bool mandatory)\r
 {\r
+    long int value;\r
     const char* txt;\r
     if (!GetString(element, key, &txt, mandatory)) return false;\r
-    *out = strtol( txt, NULL, 0 );\r
+    if (!CheckInteger(txt, false))\r
+    {\r
+        UcsXml_CB_OnError("key='%s' contained invalid integer='%s'", 2, key, txt);\r
+        return false;\r
+    }\r
+    value = strtol( txt, NULL, 0 );\r
+    if (value > 0xFF)\r
+    {\r
+        UcsXml_CB_OnError("key='%s' is out of range='%d'", 2, key, value);\r
+        return false;\r
+    }\r
+    *out = value;\r
     return true;\r
 }\r
 \r
@@ -508,6 +561,13 @@ static bool GetPayload(mxml_node_t *element, const char *name, uint8_t **pPayloa
             assert(false);\r
             return 0;\r
         }\r
+        if (!CheckInteger(token, true))\r
+        {\r
+            UcsXml_CB_OnError("Script payload contains non valid hex number='%s'", 1, token);\r
+            free(txtCopy);\r
+            assert(false);\r
+            return 0;\r
+        }\r
         p[offset + len++] = strtol( token, NULL, 16 );\r
         token = strtok_r( NULL, " ,.-", &tkPtr );\r
     }\r
@@ -650,29 +710,30 @@ static ParseResult_t ParseAll(mxml_node_t *tree, UcsXmlVal_t *ucs, PrivateData_t
         if (Parse_Success != (result = ParseNode(sub, priv)))\r
             return result;\r
         /*/Iterate all connections. Node without any connection is also valid.*/\r
-        if (!GetElementArray(sub->child, ALL_CONNECTIONS, &conType, &con))\r
-            continue;\r
-        while(con)\r
+        if (GetElementArray(sub->child, ALL_CONNECTIONS, &conType, &con))\r
         {\r
-            const char *socTypeStr;\r
-            MSocketType_t socType;\r
-            mxml_node_t *soc;\r
-            memset(&priv->conData, 0, sizeof(ConnectionData_t));\r
-            if (Parse_Success != (result = ParseConnection(con, conType, priv)))\r
-                return result;\r
-            /*Iterate all sockets*/\r
-            if(!GetElementArray(con->child, ALL_SOCKETS, &socTypeStr, &soc)) RETURN_ASSERT(Parse_XmlError);\r
-            while(soc)\r
+            while(con)\r
             {\r
-                if (!GetSocketType(socTypeStr, &socType)) RETURN_ASSERT(Parse_XmlError);\r
-                if (Parse_Success != (result = ParseSocket(soc, (0 == priv->conData.sockCnt), socType, &priv->conData.jobList, priv)))\r
+                const char *socTypeStr;\r
+                MSocketType_t socType;\r
+                mxml_node_t *soc;\r
+                memset(&priv->conData, 0, sizeof(ConnectionData_t));\r
+                if (Parse_Success != (result = ParseConnection(con, conType, priv)))\r
                     return result;\r
-                ++priv->conData.sockCnt;\r
-                if(!GetElementArray(soc, ALL_SOCKETS, &socTypeStr, &soc))\r
+                /*Iterate all sockets*/\r
+                if(!GetElementArray(con->child, ALL_SOCKETS, &socTypeStr, &soc)) RETURN_ASSERT(Parse_XmlError);\r
+                while(soc)\r
+                {\r
+                    if (!GetSocketType(socTypeStr, &socType)) RETURN_ASSERT(Parse_XmlError);\r
+                    if (Parse_Success != (result = ParseSocket(soc, (0 == priv->conData.sockCnt), socType, &priv->conData.jobList, priv)))\r
+                        return result;\r
+                    ++priv->conData.sockCnt;\r
+                    if(!GetElementArray(soc, ALL_SOCKETS, &socTypeStr, &soc))\r
+                        break;\r
+                }\r
+                if(!GetElementArray(con, ALL_CONNECTIONS, &conType, &con))\r
                     break;\r
             }\r
-            if(!GetElementArray(con, ALL_CONNECTIONS, &conType, &con))\r
-                break;\r
         }\r
         ++ucs->nodSize;\r
         if (!GetElement(sub, NODE, false, &sub, false))\r
@@ -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*/\r
     if(GetElement(tree, SCRIPT, true, &sub, false))\r
     {\r
+        bool found = true;\r
+        struct UcsXmlScript *scrlist = priv->pScrLst;\r
         while(sub)\r
         {\r
             result = ParseScript(sub, priv);\r
@@ -695,6 +758,18 @@ static ParseResult_t ParseAll(mxml_node_t *tree, UcsXmlVal_t *ucs, PrivateData_t
             if(!GetElement(sub, SCRIPT, false, &sub, false))\r
                 break;\r
         }\r
+        /* Check if all scripts where referenced */\r
+        while(NULL != scrlist)\r
+        {\r
+            if (!scrlist->inUse)\r
+            {\r
+                UcsXml_CB_OnError("Script not defined:'%s', used by node=0x%X", 1, scrlist->scriptName, scrlist->node->signature_ptr->node_address);\r
+                found = false;\r
+            }\r
+            scrlist = scrlist->next;\r
+        }\r
+        if (!found)\r
+            RETURN_ASSERT(Parse_XmlError);\r
     }\r
     return result;\r
 }\r
@@ -756,7 +831,7 @@ static ParseResult_t ParseNode(mxml_node_t *node, PrivateData_t *priv)
                 UcsXml_CB_OnError("Unknown Port:'%s'", 1, txt);\r
                 RETURN_ASSERT(Parse_XmlError);\r
             }\r
-            if(!GetElementArray(port, ALL_SOCKETS, &txt, &port))\r
+            if(!GetElementArray(port, ALL_PORTS, &txt, &port))\r
                 break;\r
         }\r
     }\r
@@ -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*/\r
     if (priv->conData.inSocket && priv->conData.outSocket)\r
     {\r
+        bool mostIsInput;\r
         bool mostIsOutput;\r
         Ucs_Rm_EndPoint_t *ep;\r
         struct UcsXmlRoute *route;\r
@@ -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));\r
         if (NULL == ep) RETURN_ASSERT(Parse_MemoryError);\r
 \r
+        mostIsInput = (UCS_XRM_RC_TYPE_MOST_SOCKET == *((Ucs_Xrm_ResourceType_t *)priv->conData.inSocket));\r
         mostIsOutput = (UCS_XRM_RC_TYPE_MOST_SOCKET == *((Ucs_Xrm_ResourceType_t *)priv->conData.outSocket));\r
+        if (!mostIsInput && !mostIsOutput)\r
+        {\r
+            UcsXml_CB_OnError("At least one MOST socket required per connection", 0);\r
+            RETURN_ASSERT(Parse_XmlError);\r
+        }\r
         ep->endpoint_type = mostIsOutput ? UCS_RM_EP_SOURCE : UCS_RM_EP_SINK;\r
         ep->jobs_list_ptr = GetJobList(*jobList, &priv->objList);\r
         if(NULL == ep->jobs_list_ptr) RETURN_ASSERT(Parse_MemoryError);\r
@@ -1102,7 +1184,7 @@ static ParseResult_t ParseScript(mxml_node_t *scr, PrivateData_t *priv)
             if (Parse_Success != result) return result;\r
         } else {\r
             UcsXml_CB_OnError("Unknown script action:'%s'", 1, txt);\r
-            /*RETURN_ASSERT(Parse_XmlError);*/\r
+            RETURN_ASSERT(Parse_XmlError);\r
         }\r
         if (!GetElementArray(act, ALL_SCRIPTS, &txt, &act))\r
             break;\r
@@ -1117,6 +1199,7 @@ static ParseResult_t ParseScript(mxml_node_t *scr, PrivateData_t *priv)
             Ucs_Rm_Node_t *node = scrlist->node;\r
             node->script_list_ptr = script;\r
             node->script_list_size = actCnt;\r
+            scrlist->inUse = true;\r
             found = true;\r
         }\r
         scrlist = scrlist->next;\r
@@ -1277,7 +1360,11 @@ static ParseResult_t ParseScriptPortCreate(mxml_node_t *act, Ucs_Ns_Script_t *sc
         speed = 0;\r
     else if (0 == strcmp(txt, I2C_SPEED_FAST))\r
         speed = 1;\r
-    else RETURN_ASSERT(Parse_XmlError);\r
+    else\r
+    {\r
+        UcsXml_CB_OnError("Invalid I2C speed:'%s'", 1, txt);\r
+        RETURN_ASSERT(Parse_XmlError);\r
+    }\r
     req = scr->send_cmd;\r
     res = scr->exp_result;\r
     req->InstId = res->InstId = 1;\r
@@ -1317,6 +1404,11 @@ static ParseResult_t ParseScriptPortWrite(mxml_node_t *act, Ucs_Ns_Script_t *scr
             mode = 1;\r
         else if (0 == strcmp(txt, I2C_WRITE_MODE_BURST))\r
             mode = 2;\r
+        else\r
+        {\r
+            UcsXml_CB_OnError("Invalid I2C mode:'%s'", 1, txt);\r
+            RETURN_ASSERT(Parse_XmlError);\r
+        }\r
     } else {\r
         mode = 0;\r
     }\r
@@ -1458,7 +1550,11 @@ static ParseResult_t ParseRoutes(UcsXmlVal_t *ucs, PrivateData_t *priv)
         }\r
         sourceRoute = sourceRoute->next;\r
     }\r
-    assert(routeAmount == ucs->routesSize);\r
+    if (routeAmount != ucs->routesSize)\r
+    {\r
+        UcsXml_CB_OnError("At least one sink (num=%d) is not connected, because of wrong Route name!", 2, (routeAmount - ucs->routesSize));\r
+        RETURN_ASSERT(Parse_XmlError);\r
+    }\r
 \r
 #ifdef DEBUG\r
     /* Third perform checks when running in debug mode*/\r
index b36e007..8aff893 100644 (file)
@@ -1,5 +1,5 @@
 /*------------------------------------------------------------------------------------------------*/\r
-/* Unicens XML Parser                                                                             */\r
+/* UNICENS XML Parser                                                                             */\r
 /* Copyright 2017, Microchip Technology Inc. and its subsidiaries.                                */\r
 /*                                                                                                */\r
 /* Redistribution and use in source and binary forms, with or without                             */\r
@@ -38,7 +38,7 @@ extern "C" {
 #include <stdint.h>\r
 #include "ucs_api.h"\r
 \r
-/** Structure holding informations to startup Unicens (UCS).\r
+/** Structure holding informations to startup UNICENS (UCS).\r
  *  Pass all these variables to the UCS manager structure, but not pInternal.\r
  *  */\r
 typedef struct\r
@@ -62,8 +62,8 @@ typedef struct
 /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/\r
 \r
 /**\r
- * \brief Initializes Unicens XML parser module, parses the given string and\r
- *        generate the data needed to run Unicens (UCS) library.\r
+ * \brief Initializes UNICENS XML parser module, parses the given string and\r
+ *        generate the data needed to run UNICENS (UCS) library.\r
  *\r
  * \note In case of errors the callback UcsXml_CB_OnError will be raised.\r
  * \param xmlString - Zero terminated XML string. The string will not be used\r
index 9350191..743598f 100644 (file)
@@ -1,5 +1,5 @@
 /*------------------------------------------------------------------------------------------------*/\r
-/* Unicens XML Parser                                                                             */\r
+/* UNICENS XML Parser                                                                             */\r
 /* Copyright 2017, Microchip Technology Inc. and its subsidiaries.                                */\r
 /*                                                                                                */\r
 /* Redistribution and use in source and binary forms, with or without                             */\r
@@ -31,6 +31,7 @@
 #include <stdlib.h>\r
 #include <string.h>\r
 #include <assert.h>\r
+#include "UcsXml.h"\r
 #include "UcsXml_Private.h"\r
 \r
 static const char* USB_PHY_STANDARD =       "Standard";\r
@@ -69,8 +70,8 @@ static const char* VAL_TRUE =               "true";
 static const char* VAL_FALSE =              "false";\r
  */\r
 \r
-#define ASSERT_FALSE() { assert(false); return false; }\r
-#define CHECK_POINTER(PTR) if (NULL == PTR) { ASSERT_FALSE(); }\r
+#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; }\r
+#define CHECK_POINTER(PTR) if (NULL == PTR) { ASSERT_FALSE(PTR, "NULL pointer"); }\r
 \r
 static int32_t Str2Int(const char *val)\r
 {\r
@@ -149,7 +150,7 @@ bool GetMostSocket(Ucs_Xrm_MostSocket_t **mostSoc, struct MostSocketParameters *
         soc->data_type = UCS_MOST_SCKT_DISC_FRAME_PHASE;\r
         break;\r
     default:\r
-        ASSERT_FALSE();\r
+        ASSERT_FALSE("GetMostSocket->dataType", "");\r
     }\r
     return true;\r
 }\r
@@ -176,7 +177,7 @@ bool GetUsbPort(Ucs_Xrm_UsbPort_t **usbPort, struct UsbPortParameters *param)
         port->physical_layer = UCS_USB_PHY_LAYER_STANDARD;\r
     else if (0 == strcmp(USB_PHY_HSIC, param->physicalLayer))\r
         port->physical_layer = UCS_USB_PHY_LAYER_HSCI;\r
-    else ASSERT_FALSE();\r
+    else ASSERT_FALSE("GetUsbPort->physical_layer", param->physicalLayer);\r
     return true;\r
 }\r
 \r
@@ -220,7 +221,7 @@ bool GetUsbSocket(Ucs_Xrm_UsbSocket_t **usbSoc, struct UsbSocketParameters *para
         soc->data_type = UCS_USB_SCKT_IPC_PACKET;\r
         break;\r
     default:\r
-        ASSERT_FALSE();\r
+        ASSERT_FALSE("GetUsbSocket->dataType", "");\r
     }\r
     soc->end_point_addr = (uint8_t)Str2Int(param->endpointAddress);\r
     soc->frames_per_transfer = (uint16_t)Str2Int(param->framesPerTrans);\r
@@ -256,7 +257,7 @@ bool GetMlbPort(Ucs_Xrm_MlbPort_t **mlbPort, struct MlbPortParameters *param)
         port->clock_config = UCS_MLB_CLK_CFG_6144_FS;\r
     else if (0 == strcmp(param->clockConfig, CLOCK_8192FS))\r
         port->clock_config = UCS_MLB_CLK_CFG_8192_FS;\r
-    else ASSERT_FALSE();\r
+    else ASSERT_FALSE("GetMlbPort->clockConfig", param->clockConfig);\r
     return true;\r
 }\r
 \r
@@ -306,7 +307,7 @@ bool GetMlbSocket(Ucs_Xrm_MlbSocket_t **mlbSoc, struct MlbSocketParameters *para
         soc->data_type = UCS_MLB_SCKT_IPC_PACKET;\r
         break;\r
     default:\r
-        ASSERT_FALSE();\r
+        ASSERT_FALSE("GetMlbSocket->dataType", "");\r
     }\r
     soc->channel_address = (uint16_t)Str2Int(param->channelAddress);\r
     soc->mlb_port_obj_ptr = param->mlbPort;\r
@@ -343,7 +344,7 @@ bool GetStrmPort(Ucs_Xrm_StrmPort_t **strmPort, struct StrmPortParameters *param
             port->clock_config = UCS_STREAM_PORT_CLK_CFG_512FS;\r
         else if (0 == strcmp(param->clockConfig, CLOCK_WILDCARD))\r
             port->clock_config = UCS_STREAM_PORT_CLK_CFG_WILD;\r
-        else ASSERT_FALSE();\r
+        else ASSERT_FALSE("GetStrmPort->clockConfig", param->clockConfig);\r
     } else {\r
         port->clock_config = UCS_STREAM_PORT_CLK_CFG_WILD;\r
     }\r
@@ -358,7 +359,7 @@ bool GetStrmPort(Ucs_Xrm_StrmPort_t **strmPort, struct StrmPortParameters *param
         port->data_alignment = UCS_STREAM_PORT_ALGN_RIGHT24BIT;\r
     else if (0 == strcmp(param->dataAlignment, STRM_ALIGN_SEQUENTIAL))\r
         port->data_alignment = UCS_STREAM_PORT_ALGN_SEQ;\r
-    else ASSERT_FALSE();\r
+    else ASSERT_FALSE("GetStrmPort->dataAlignment", param->dataAlignment);\r
     return true;\r
 }\r
 \r
@@ -382,7 +383,7 @@ bool GetStrmSocket(Ucs_Xrm_StrmSocket_t **strmSoc, struct StrmSocketParameters *
         soc->data_type = UCS_STREAM_PORT_SCKT_SYNC_DATA;\r
         break;\r
     default:\r
-        ASSERT_FALSE();\r
+        ASSERT_FALSE("GetStrmSocket->dataType", "");\r
     }\r
     soc->bandwidth = param->bandwidth;\r
     if (0 == strcmp(param->streamPin, I2S_PIN_SRXA0))\r
@@ -409,7 +410,7 @@ bool GetStrmSocket(Ucs_Xrm_StrmSocket_t **strmSoc, struct StrmSocketParameters *
         soc->stream_port_obj_ptr = param->streamPortB;\r
         return true;\r
     }\r
-    else ASSERT_FALSE();\r
+    else ASSERT_FALSE("GetStrmSocket->streamPin", param->streamPin);\r
     return true;\r
 }\r
 \r
@@ -462,7 +463,7 @@ bool GetSyncCon(Ucs_Xrm_SyncCon_t **syncCon, struct SyncConParameters *param)
         con->mute_mode = UCS_SYNC_MUTE_MODE_NO_MUTING;\r
     else if (0 == strcmp(param->muteMode, MUTE_SIGNAL))\r
         con->mute_mode = UCS_SYNC_MUTE_MODE_MUTE_SIGNAL;\r
-    else ASSERT_FALSE();\r
+    else ASSERT_FALSE("GetSyncCon->mute_mode", param->muteMode);\r
     if (param->optional_offset)\r
         con->offset = (uint16_t)Str2Int(param->optional_offset);\r
     else\r
@@ -501,7 +502,7 @@ bool GetAvpCon(Ucs_Xrm_AvpCon_t **avpCon, struct AvpConParameters *param)
             con->isoc_packet_size = UCS_ISOC_PCKT_SIZE_206;\r
             break;\r
         default:\r
-            ASSERT_FALSE();\r
+            ASSERT_FALSE("GetAvpCon->isoc_packet_size", "");\r
         }\r
     } else {\r
         con->isoc_packet_size = UCS_ISOC_PCKT_SIZE_188;\r
index f8df323..964a7ad 100644 (file)
@@ -1,5 +1,5 @@
 /*------------------------------------------------------------------------------------------------*/\r
-/* Unicens XML Parser                                                                             */\r
+/* UNICENS XML Parser                                                                             */\r
 /* Copyright 2017, Microchip Technology Inc. and its subsidiaries.                                */\r
 /*                                                                                                */\r
 /* Redistribution and use in source and binary forms, with or without                             */\r
index 93bba34..0a47ae4 100644 (file)
@@ -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!
index 5f02851..d7a1f66 100644 (file)
@@ -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
index ad256e3..58b49d9 100644 (file)
@@ -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)
     {