Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

send break signal after write termination

When i set the WriteTermination property to Break the write functions doesn't work.

VC#.net code

Init code

mbSession = (SerialSession)ResourceManager.GetLocalManager().Open(resourceString);

mbSession.WriteTermination = SerialTerminationMethod.Break; // if i include this line,  Write function doesn't work,

 

write function

mbSession.Write(writeBuf);  // this function does't work if WriteTermination is set to SerialTerminationMethod.Break  it immediatly send break signal

0 Kudos
Message 1 of 8
(4,405 Views)
Hi Jan_hk,
Does the Write function work if you use another termination method, ie. last bit or termination character or none?  (Check the Measurement Studio help file for details on the different termination methods if needed) It sounds like the write buffer may be empty when the session break occurs, so the break may be happening before the write.  Do you see any kind of error or anything?  Let me know and I will look into it further for you.  Have a great day!
 
Chris R.
Applications Engineer
National Instruments
Chris R.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 8
(4,372 Views)
Hello Chris
 
The write funcion works with all other :

mbSession = (SerialSession)ResourceManager.GetLocalManager().Open(sr.ResourceName);

// mbSession.WriteTermination = SerialTerminationMethod.LastBit; //works

// mbSession.WriteTermination = SerialTerminationMethod.None; //works

// mbSession.WriteTermination = SerialTerminationMethod.None; // works

mbSession.WriteTermination = SerialTerminationMethod.Break;

//does not work

 none, term
 
 
I modified the SimpleReadWrite example supplied by NI
I just replaced MessageBasedSession to SerialSession and include above line.
I checked the output by connecting 2 serial port by null modem cable .
I also checked on a second computer.
 
Enclosed the modified file
 
Regards, Jan
 
0 Kudos
Message 3 of 8
(4,356 Views)

Hi Jan,

Is there possibly a problem with your instrument responding to this command?  Can you use the other termination methods or is the Break needed.  I know this is just a workaround for now, but I wanted to check anyway.  What instrument and software are you using?  With this information, I may be able to check known bugs in the software to see if this may be the problem.  Are you using an NI-Serial device?  If so, which one and what version of the NI-Serial drivers are you using?  Let me know and I will look further into your issue.

Chris R.

Chris R.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 8
(4,324 Views)

Hello Chris

Break signal is defined in the LIN bus standard used in automotive applications

before each transfer  a break signal has to be generated of at least 13 bits long. For testing our application according the LIN-bus i thus need to generate the break signal.

I didn't check yet, if manually generating the break signal by the brake state property works.

Regards, Jan

 

 

 

0 Kudos
Message 5 of 8
(4,321 Views)
Hi Jan,
That is the next step I would suggest. (Manually generating the break).  The function VI_ATTR_ASRL_BREAK_STATE with VI_STATE_ASSERTED and VI_STATE_UNASSERTED may get what you need.  If you look in the VISA Help File (linked in the start menu of windows in the VISA folder), and search for the function, you can find more information there.  It places the transmission line in a break state for a certain number of milliseconds.  Unfortunately, we do not support LIN Bus as of yet, so I am unsure of the best way to generate the 13 bit break needed for it.  Hopefully we can get something working for you.  Let me know if this function doesn't work and I will attempt to find something else for you.  Have a great day!
 
Chris R.
Applications Engineer
National Instruments
Chris R.
Applications Engineer
National Instruments
0 Kudos
Message 6 of 8
(4,290 Views)

Hello Chris

 

I use VC#. Following code works. Do you have any function available to wait for fixed nr of milliseconds to replace the for loop.

mbSession.BreakState = LineState.Asserted;

for (i=0; i<200000;i++);

mbSession.BreakState = LineState.Unasserted;

regards, Jan

0 Kudos
Message 7 of 8
(4,275 Views)
you could use Thread.Sleep(int) and pass in the number of milliseconds to wait:
 
using System.Threading;
 
Thread.Sleep(500) //thread sleeps for 500 milliseconds.
0 Kudos
Message 8 of 8
(4,267 Views)