01-15-2016 09:06 AM
Setup: The setup I have is a loop back connection between PXI 2 port LIN board. I am using XNET LIN loopback example where I have modified the example to use ":memory:" to create session for "nxMode_FrameInStream" and "nxMode_FrameOutStream".
Question: I got this example to work where the master session would write and slave session would read the frame. (I use an ID:1 and Payload:8 byte and read it back through slave session). I am not using any scheduling.
Now I would want to do the other way round where master would read data and slave would provide it. So to start with I create 2 sessions for each interface/channel of which one interface is master and other is slave. Based of this I call nxWriteFrame on slave output session and try to receive it by nxReadFrame with master input session.
I do not get any data back and the buffer is always empty.
Can anyone explain me why this doesn't work?
I want to test all scenarios where master and slave would request and receive and would like to know if I am on the right path.
Note: Attached is the I/O trace log and C code file
01-18-2016 03:22 AM
Hi there,
A frame cannot usually be sent from a slave on its own. Basically, the master will ignore it because no frame header was sent to the slave beforehand. To perform a write operation from a slave without having an explicit request (like in diagnostic frames), the master needs to know about this frame through the use of a schedule.
So you got it: the solution is to create a schedule containing the frames to be written and read from/to the master. And this includes the slave frames. This way, in its frame slot, the master will send a header to the LIN network. A slave (possibly multiple) will subscribe to this frame, and send data back to the master when the XNET Write occurs on the slave interface (or previous data depending on the frame type).
Pro tip: it usually gets hard to maintain an app with :memory: database. Creating a database is the way to go in 99% of cases.
I suggest you to read the NI-XNET Hardware & Software Manual to get a more thorough understanding of the LIN protocol and the way to use it with NI products. I know that PDF is this big, but it really helps 😄
Regards,
Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.
01-18-2016 07:28 AM
Thank you Eric for your response.
The application I am working have being using ":memory:" as datasource, hence I am using example code to do the same. I have being referring the documentation but didn't find direct answers to my questions.
So, based on your suggestion I have to have a schedule defined for all frames which master and slave will communicate with.
How do I define schedule for ":memory:" databse using C API? Which functions I need to call? Do you have an example of which I can work off?
01-19-2016 11:16 AM
I think what Eric was referring to was creating a Database in the XNET API Database Editor. You can find a bit more info on it here http://www.ni.com/white-paper/9715/en/. You should be able to access the Database Editor on your computer, it will be a separate program. All of this is done using a UI interface. So in short you're creating a database file which you reference instead of creating the database object in memory. The manual talks a bit about it here http://www.ni.com/pdf/manuals/372840h.pdf#page=77.
01-19-2016 11:19 AM
The C API info is on this page in the manual http://www.ni.com/pdf/manuals/372840h.pdf#page=689. Sorry about that.
01-26-2016 12:35 PM - edited 01-26-2016 12:35 PM
Thanks Da_Parrot for the information.
For my test app I used the Database Editor to add Cluster,Frame, and ECU information. And that works which is the same as some sample examples which I tested with the example database.
But for my actual application this approach would not work as I have to create this database information on the fly with the given frame information I have. Thus, I need a way to do this using C API?
01-27-2016 04:05 PM
I think you will be able to find the frame in the database and alter it in memory using nxdbFindObject and nxdbSetProperty on page 690 (5-7) of the NI-XNET Hardware and Software Manual that Da_Parrot linked
01-28-2016 12:43 PM
@DangerDave : I already started implementing on the fly database using nxdbCreateObject and setting properties using nxdbSetProtperty.
The problem now I am facing is during nxCreateSessionByRef call gives following error. (Since I already have the ":memory:" reference from the nxdbOpenDatabse call I use nxCreateSessionRef)
"NI-XNET Status: NI-XNET: (Hex 0xBFF630C0) A property value was out of range or incorrect. Solution: specify a correct value."
Not sure why I am getting this error?
Note: I have attached the trace log for reference.
01-29-2016 04:19 PM
It sounds like your reference to the memory location might be changing when you update the database on the fly. Can you reacquire the reference each time you make a change?
02-01-2016 09:17 AM
@DangerDave : I tried to open databse (":memory:") again before creating session just to make sure that I have valid reference. But this does not help and I get the same error.