lwip: using LWIP_PBUF_CUSTOM_DATA together with socket api - sockets

I'm trying to port a project to lwip. This project uses BSD sockets calls, so first, I used lwip's socket APIs.
The project I'm trying to port has to deal with packet timestamping, that's why I used LWIP_PBUF_CUSTOM_DATA as explained here https://savannah.nongnu.org/bugs/?55078
This way I can "enrich" the pbuf structure with metadata fields of my own.
The question is: how do I retrieve my metadata using the socket API? For example how do I get a read pbuf? Or how do I convert the socket to a netconn?

Related

OPC server create model information from existing nodeset file

I have a task that is create an opc server and instantaneously read data from an injection molding cnc machine with opc client. I have read a lot of documentation and came to a conclusion which I need a model information xml file and create c# classes with a compiler according to the model information file.
I have come across with OPCFoundation/UA-Nodeset repository which has Node Id's that plastic rubber devices shares.(I assume that) There is also a Opc.Ua.PlasticsRubber.IMM2MES.NodeSet2.xml file which is the final ingredient that model compiler produces.
Also I assume when I point my opc server address to the molding cnc device, I will read or machine push data with those spesific nodeIds.(I might be awfully wrong here)
Now the confusion begins here; In the Opc.Ua.PlasticsRubber.IMM2MES.NodeSet2.xml, there are some nodeIds presented. Is the data presented by the molding device published with that nodeIds or those id's are just a unique key for model file? Also when I try to create model information file, nodeId's are different. Is nodeIds should match with the nodeset2.xml?
In the end, I want to read lets say machine status data which nodeId is 5006, should match the model information file which I created in order to get data?
Thank you.
The nodeset in the Companion Specification usually contains only Types (such as ObjectTypes, VariableTypes, etc.) and sometimes an object that serves as an entry point (e.g. DeviceSet of DI). To use these types, you need to create an instance of an object in the address space of your OPC UA server. For example, in your case, the instance might be of the IMM_MES_InterfaceType. The nodes of your instance will have different nodeIds than the types.
As an OPC UA client, you should use the BrowsePath (and the browse service) to locate the correct node in the address space. Once you have the nodeId, you can read or write data from it. In the first step, you can use a generic OPC UA client such as UaExpert for browsing, but it is recommended to implement browsing in your own application. This will allow you to connect to other machines with the same interface.
In think your BrowsePath for the MachineStatus should something like this:
Objects.DeviceSet.IMM_<Manufacturer>_<SerialNumber>.MachineStatus
An example of an plastic rubber devices should be here

How to send the data using Eclipse Milo OPC Server

I want to send data generated by my application to OPC UA client using OPC UA Server. I have gone through Eclipse Milo Project which is great resource for the same. But I don't know how to integrate it in our Application.The Application produces output in JSON format. The data of multiple nodes is stored, processed and sent using JSON format like following.
{"deviceId":"36860","timestamp":"2019-03-07 10:37:20+05:30","1":"228.6","2":"237.65","3":"237.21","4":"0.13","5":"0.0","6":"0.11","7":"-2.95","8":"0.0","9":"4.03","10":"22.2","11":"0.0","12":"16.43","13":"-21.83","14":"0.0","15":"-15.72","16":"-0.13","17":"1.0","18":"0.25","19":"262.35","20":"0.0","21":"284.18","22":"234.49","23":"703.47","24":"0.08","25":"0.24","26":"0.36","27":"1.08","28":"12.87","29":"38.62","30":"-12.52"}
where 36860 is the nodeId/deviceId, timestamp is the time when data is captured from the node rest are the Parameter Ids and their actual reading values of node in key value pair.
How to use the ExampleServer to send this data and How client would receive it ?
If possible can anyone provide an example ?
I think the first think you should decide is how to model the data in the server.
You could of course stuff that String into a single VariableNode with DataType of String but then why bother using OPC UA?

Can I find what network interface/device is handling my socket?

Say I've got a file descriptor from socket(2) and I've done a connect(2) on it -- is there any way later to determine (from inside the running program) what network device might be in use for the underlying transport? A call to stat(2) on the fd gives a device number of 0; none of the ioctl(2) or getsockopt(2) options seem applicable.
There's no foolproof way to do so -- certainly not a posix-compliant way.
However, in practice, you can easily determine the interface 99% of the time. After you've done the connect, use getsockname to obtain the IP address, then look through the list of available interfaces on the box for one with a matching IP address.
From the accept call you should be able to get the remote client's ip address (seen here on Beej's). Assuming you do not have any asymmetric routes, you can look up the route to that address in your local routing table. The routing table should tell you what ethernet device is used to send packets to the remote client.
EDIT:
you could use the following command line tool to query your local routing table with the remote client's address:
ip route get <remote-client-ip-addr>

CDA HL7V3 acknowledgement

I create using Mirth a channel that receives CDA messages in HL7V3 format.
I'm able to parse the message and extract all the data i need.
My question is: How do i create an acknowledgement to the receiver?
I found out that there is a message called MCCI_MT000200UV01 that i need to implement but i can't find good explanation and/or examples.
I have been working a long time with HL7V2 and the acknowledgement is very simple.
Can't find a way to implement this in HL7V3 format.
Thanks in advance for your help
I guess you are talking about a generic Accept Acknowledgment message which is MCCI_IN000002UV02 (according to the HL7v3 NE2014). If I were you, first thing to do I'd download the HL7v3 Normative Edition that matches the year of your inbound message used to transport the CDA document (unless it's HL7v2). Then I'd go to HL7v3NE > Specification Infrastructure > Messaging > Transmission Infrastructure > Generic Message Transmission and find the Accept Ack interaction. There is a related XML Schema that allows you to build an XML template for the v3 ACK (XMLSpy like tool does that by default).
Since ACKGenerator does not support HL7v3, next step is to create a code templates function that builds the v3 ACK from the template you acquired from the previous step.
(PS. The whole procedure with samples is explained in an "Unofficial Mirth Connect Developer's Guide" available at mirthconnect.shamilpublishing.com)

How do I set up a mock queue using mockrunner to test an xml filter?

I'm using the mockrunner package from http://mockrunner.sourceforge.net/ to set up a mock queue for JUnit testing an XML filter which operates like this:
sets recognized properties for an ftp server to put and get xml input and a jms queue server that keeps track of jobs. Remotely there waits a server that actually parses the xml once a queue message is received.
creates a remote directory using ftp and starts a queue connection using mqconnectionfactory to the given address of the queue server.
once the new queue entry is made in 2), the filter waits for a new queue message to appear signifying the job has been completed by the remote server. The filter then grabs the modified xml file from the ftp and passes it along to the next filter.
The JUnit test I am working on simply needs to emulate this environment by starting a local ftp and mock queue server for the filter to connect to, then waiting for the filter to connect to the queue and put the new xml input file on a local directory via a local ftp server, wait for the queue message and then modify the xml input slightly, put the modified xml in a new directory and post another message to the queue signifying the job has completed.
All of the tutorials I have found on the net have used EJB and JNDI to lookup the queue server once it has been made. If possible, I'd like to sidestep that route by just creating a mock queue on my local machine and connecting to it in the simplest manner possible, not using EJB and JNDI.
Thanks in advance!
I'm using MockEjb and there are some examples among them one for using mock queues, so take a look to the info and to the example
Hopefully it helps.
I'd recommend having a look at using Apache Camel to create your test case. Then its really easy to switch your test case from any of the available components and most importantly Camel comes with some really handy Mock Endpoints which makes it super easy to test complex routing logic particularly with asynchronous operations.
If you also use Spring, then maybe start by trying out these Spring unit tests with mock endpoints in Camel which let you inject the mock endpoints to perform assertions on together with the ProducerTemplate object to make it really easy to fire your messages for your test case. e.g. see the last example on that page.
Start off using simple endpoints like the SEDA endpoint - then when you've got your head around the core spring/mock framework, try using the JMS endpoint or FTP endpoint endpoints etc.