DMA buffer mapping to array?

Hi all!
I'm working with a DMA capable camera that mapps images to a DMA buffer which is accessible from the native side. What I would like to do is to get access to the buffer from the Java side (e.g. as a byte array) without performing a copy operation. So to speak "point" the byte array to a specific memory adress containing the DMA buffer. Is this possible? If yes, how do I go about it?
Currently I'm copying data from the DMA buffer to a byte array member variable at each read. But if possible it would be nice to remove the extra overhead this operation introduces.
Thanks in advance,
/ Anders

Hi Hervé,
thank you for pointing to the UG section, indeed very powerful stuff!
By using it I will be able to structure my data according to fit any external requirement.
Attached is the test project where you can see that a (8 bit) data structure in SW memory
is different from the generated HDL port structure (as described in my first post here).
Looking at the HDL output I see that one part, the R member what is set to constant,
is mapped 4 times to the lower side of the slv120 vector followed by the variable part.
I do not understand this mapping, it prevent effective work as it forces the user to figure out
how the actual mapping is applied and to remap this to the required structure.
More critical, what if in further version of the tool this mapping schema changes ???
Any idea how I can avoid the extra work?
Thanks,
Ric.
d_o_TDATA : OUT STD_LOGIC_VECTOR (95 downto 0);
d_o_TDATA <= OUTPUT_STREAM_1_data_reg;
-- OUTPUT_STREAM_1_data_reg assign process. --
OUTPUT_STREAM_1_data_reg_assign_proc : process(ap_clk)
begin
if (ap_clk'event and ap_clk = '1') then
if (ap_rst_n_inv = '1') then
OUTPUT_STREAM_1_data_reg(0) <= '0'; -- .data.Pix[0].R
OUTPUT_STREAM_1_data_reg(8) <= '0'; -- .data.Pix[1].R
OUTPUT_STREAM_1_data_reg(16) <= '0';-- .data.Pix[2].R
OUTPUT_STREAM_1_data_reg(24) <= '0';-- .data.Pix[3].R
OUTPUT_STREAM_1_data_reg(32) <= '0';-- .data.Pix[0].G
OUTPUT_STREAM_1_data_reg(33) <= '0';
OUTPUT_STREAM_1_data_reg(34) <= '0';
OUTPUT_STREAM_1_data_reg(94) <= '0';
OUTPUT_STREAM_1_data_reg(95) <= '0';
 

Similar Messages

  • How to structure the DMA buffer for PXie 6341 DAQ card for analog output with different frequencies on each channel

    I'm using the MHDDK for analog out/in with the PXIe 6341 DAQ card.
    The examples, e.g. aoex5, show a single Timer  (outTimerHelper::loadUI method), but the example shows DMA data loaded with the same vector size.
    There is a comment in the outTimerHelper:rogramUpdateCount call which implies that different buffer sizes per channel can be used.
       (the comment is: Switching between different buffer sizes will not be used)
    Does anyone know what the format of the DMA buffer should be for data for multiple channels with different frequencies ?
    For example, say we want a0 with a 1Khz Sine wave and a1 with a 1.5Khz sine wave.  What does the DMA buffer look like ?
    With the same frequency for each channel, the data is interleaved, e.g.  (ao0#0, ao1#0; ao0#1, ao1#1, ...), but when the frequencies for each channel is different, what does the buffer look like ?

    Hello Kenstern,
    The data is always interleaved because each card only has a single timing engine for each subsystem.
    For AO you must specify the number of samples that AO will output. You also specify the number of channels. Because there is only one timing engine for AO, each AO will channel will get updated at the same time tick of the update clock. The data will be arranged interleaved exactly as the example shows because each AO channel needs data to output at each tick of the update clock. The data itself can change based on the frequency you want to output.
    kenstern wrote:
    For example, say we want a0 with a 1Khz Sine wave and a1 with a 1.5Khz sine wave.  What does the DMA buffer look like ?
    With the same frequency for each channel, the data is interleaved, e.g.  (ao0#0, ao1#0; ao0#1, ao1#1, ...), but when the frequencies for each channel is different, what does the buffer look like ?
    In your example, you need to come up with an update rate that works for both waveforms (1 KHz and 1.5 KHz sine waves). To get a good representation of a sine wave, you need to update more than 10x as fast as your fastest frequency...I would recommend 100x if possible.
    Update Frequency: 150 KHz
    Channels: 2
    Then you create buffers that include full cycles of each waveform you want to output based on the update frequency. These buffers must also be the same size.
    Buffer 1: Contains data for the 1 KHz sine wave, 300 points, 2 sine wave cycles
    Buffer 2: Contains data for the 1.5 KHz sine wave, 300 points, 3 sine wave cycles
    You then interleave them as before. When the data is run through the ADC, they are outputting different sine waves even though the AO channels are updating at the same rate.

  • How to map an array to fixed fields using Biztalk mapper

    I need to remap an array of objects like this:
        <Root>
          <ListOfObjs>
            <Obj>
              <Attr1>0000</Attr1>
              <Attr2>Hello!</Attr2>
            </Obj>
            <Obj>
              <Attr1>1111</Attr1>
              <Attr2>Hello1!</Attr2>
            </Obj>
          </ListOfObjs>
        </Root>
    in an output like this:
            <Root>
                <Obj1_Attr1>0000</Obj1_Attr1>
                <Obj1_Attr2>Hello!</Obj1_Attr2>
                <Obj2_Attr1>1111</Obj2_Attr1>
                <Obj2_Attr2>Hello1!</Obj2_Attr2>
            </Root>
    So in my XSD schema I have something like this:
    Schema Input
                               <xs:element name="Root">
                                <xs:complexType>
                                 <xs:sequence>
                                  <xs:element name="ListOfObjs">
                                   <xs:complexType>
                                    <xs:sequence>
                                     <xs:element name="Obj">
                                      <xs:complexType>
                                       <xs:sequence>
                                        <xs:element name="Attr1">
                                         <xs:simpleType>
                                          <xs:restriction base="xs:string">
                                           <xs:minLength value="1"/>
                                           <xs:maxLength value="50"/>
                                          </xs:restriction>
                                         </xs:simpleType>
                                        </xs:element>
                                       <xs:element name="Attr2">
                                        <xs:simpleType>
                                          <xs:restriction base="xs:string">
                                           <xs:minLength value="1"/>
                                           <xs:maxLength value="50"/>
                                          </xs:restriction>
                                         </xs:simpleType>
                                        </xs:element>
                                       </xs:sequence>
                                      </xs:complexType>
                                     </xs:element>
                                    </xs:sequence>
                                   </xs:complexType>
                                  </xs:element>
    Schema output
                                     <xs:element name="Root">
                                      <xs:complexType>
                                       <xs:sequence>
                                        <xs:element name="Obj1_Attr1">
                                         <xs:simpleType>
                                          <xs:restriction base="xs:string">
                                           <xs:minLength value="1"/>
                                           <xs:maxLength value="50"/>
                                          </xs:restriction>
                                         </xs:simpleType>
                                        </xs:element>
                                       <xs:element name="Obj1_Attr2">
                                        <xs:simpleType>
                                          <xs:restriction base="xs:string">
                                           <xs:minLength value="1"/>
                                           <xs:maxLength value="50"/>
                                          </xs:restriction>
                                         </xs:simpleType>
                                        </xs:element>
                                        <xs:element name="Obj2_Attr1">
                                        <xs:simpleType>
                                          <xs:restriction base="xs:string">
                                           <xs:minLength value="1"/>
                                           <xs:maxLength value="50"/>
                                          </xs:restriction>
                                         </xs:simpleType>
                                        </xs:element>
                                        <xs:element name="Obj2_Attr2">
                                        <xs:simpleType>
                                          <xs:restriction base="xs:string">
                                           <xs:minLength value="1"/>
                                           <xs:maxLength value="50"/>
                                          </xs:restriction>
                                         </xs:simpleType>
                                        </xs:element>
                                       </xs:sequence>
                                      </xs:complexType>
                                     </xs:element>
    In addiction I have to evaluate every single value because when I found some conditions (like if value=0000 output should be NULL).
    What would be the best way to do it? I'm thinking to develop a custom functoid but I'm not sure it would be the best way, probably it could be done even using XSLT inline transforms, can you point me in the best direction?
    Thank you

    Hi,
    You cannot directly map an array output to any single field in BizTalk mapper.
    Couple of options :
    1) create
    the Xslt or inline C# code
    Refer: 
    http://seroter.wordpress.com/2008/10/07/splitting-delimited-values-in-biztalk-maps/
    2) Shankycheil has
    provided a solution to similar requirement in the below link, u can also refer that.
    https://social.msdn.microsoft.com/Forums/en-US/55ec472d-4f34-4057-b1c6-0e50740f0f6e/how-to-itterate-string-array-values-in-biztalk-mapper?forum=biztalkgeneral
    Rachit
    Thank you, I already seen both posts, but I'm not sure they are what I need or I can't understand well how to use them.
    Speaking about the first solution, as I told before, in the example I should have an array already formed and delimited by a char (something like "obj1attr1-obj1attr2-ob2attr1-obj2attr2". In this situation probably this example could be a good
    point to start from, but how to transform my complex input object in a similar formatted string?
    About the second I don't understand well what is the working solution that they have adopted. Is the 4 steps solution suggested by  Shankycheil? If yes, how can I loop between all array elements and extract all their values?

  • Mapping Java Arrays

    I was given an object model generated by an apache product, Axis. The generated java files use the Java Array in the following fashion:
    Class Zoo {
    private ArrayOfAnimals animals;
    // … public get/set methods cut
    Class ArrayOfAnimals {
    private Animal animals[];
    // … public get/set methods cut
    Class Animal {
    private String name;
    // … public get/set methods cut
    I was tasked with mapping the one-to-many relationship between zoo and an array of animals using the Animal array. I can’t find a mapping in TopLink to do this type of association. I am NOT allowed to modify the generated source code. I may be able to extend the generated classes, and perhaps provide a different superclass.
    I am allowed to create the relational model for these domain classes. Can anyone help with this type of mapping?
    Thanks

    TopLink does not directly support arrays as the mapping type for a collection, only collection types that support the Collection and Map interfaces.
    In general it seems odd to use an array instead of a Java collection which would be much more efficient (in terms of adding and removing) and much more functional. I would definitely suggest changing the generated code, or the way the code is generated if at all possible.
    The easiest way to map the array in TopLink would be the use get/set methods for the 1-m mapping on the Zoo class that converted the array to/from a Collection.
    i.e. something like,
    public List getAnimalsList() {
    return new Arrays.asList(animals.animals);
    public void setAnimalsList(List list) {
    animals.animals = (Animal[]) list.toArray();
    In general TopLink uses its ContainerPolicy class to handle collections. It may also be possible (but advanced) to write a custom container policy for your 1-m mapping that handles arrays.

  • Mapping of Array Structucture

    I am trying to map SOAP response ( which is combination of an array and a separate String field) as Source Message . I need to map it to  Target Message with same structure.
    <b>Do I need to use user defined functions to map source array element to target array element?</b>
    Direct mapping ( 1-1) does not seem to do the job. It only displays and maps the string field which is not part of Array.
    Appreciate your prompt response

    Hi Prasad,
    If the source and target have the same structures then you don't need any user defined functions. Infact  you don't need any interface mapping program if it is the same  message type on both the sides while sending to the target. If these are two different message types of the similar field names then you can use the identity mapping in IR to map them.
    >>It only displays and maps the string field which is not part of Array.
    check the cardinality(occurance) of this field in the bothe structures. Also if your array field is a child element of the node then make sure that you map the parent nodes aswell.
    Check the context of the source field and you can use 'display queue' functionality while testing your mappings in IR.
    hope this helps..
    Anand

  • Mapping vertical arrays versus horizontal arrays in HP exstream

    Anyone with details on mapping vertical arrays versus horizontal arrays in HP Streak software please?

    johnsold wrote:
    Is this a bug (inconsistent behavior)? A feature? An unintended consequence of something else?
    I agree, this looks inconsistent.
    Ranjeet_Singh wrote:
    Make the index of both the array 0 then run your program. 
    Now horizontal array shows 4th element & vertical array shows 10th element. 
    What are you trying to say here? You are just repeating the instruction #1 on the front panel of the posted VI, then repeating what the image above already shows.
    LabVIEW Champion . Do more with less code and in less time .

  • Read Video data from buffer or byte array

    Hi guys,
    I've developed a tx/rx module, the tx read an mpg file and transfer it over network. rx has the data in a byte array, I also feed the byte array to a media buffer. Now my question is how to creat the player and feed the player to play the content of the buffer or byte array?
    I would really appreaciate if someone could help me please...
    Thanx
    I haven't and didn't want to use any of the RTP stuff...

    Hi, I tried PullBufferDataSource. What I am trying to do is : read a .wav file into a queue, then construct a datasource with this queue. The processor will be contructed to process the datasource, and a datasink to sink data to a file. I think if this workflow could work, it should work in network transmission.
    In fact the code works partially. The trick part is the read( Buffer ) method. If I try to use 'if' statement to see if Queue has empty or not, the datasink could not format the head part of output file correctly. If I didnot use 'if' statement, the program will terminate when exception occurs. The output file is all right.
    I did not understand what is going on.
    Note: the original file is a RAW data file without format info.
    Here is the code fragments. Hopefully we can work together to figure it out.
    Thanks.
    Jim
    * QueueDataSourceTester.java
    * Created on November 11, 2002, 10:29 AM
    package bonephone;
    import javax.media.*;
    import javax.media.control.*;
    import javax.media.protocol.*;
    import javax.media.datasink.*;
    import javax.media.format.AudioFormat;
    import java.util.LinkedList;
    import java.io.*;
    * @author wguo
    public class QueueDataSourceTester implements ControllerListener, DataSinkListener {
    protected LinkedList myQueue;
    /** Creates a new instance of QueueDataSourceTester */
    public QueueDataSourceTester() {
    myQueue = new LinkedList();
    public void testIt( ){
    // Read a file into a Queue
    FileInputStream inputStream = null;
    try{
    inputStream = new FileInputStream( "c:/media/phone.wav");
    catch( IOException ioe ){
    System.err.println( "Error on open media file." );
    try{
    byte data[] = new byte[1024];
    int n ;
    while( ( n = inputStream.read( data, 0, 1024 )) != -1 ){
    myQueue.addLast( data );
    data = new byte[1024];
    inputStream.close();
    catch( IOException ioe ){
    System.err.println( "Error on reading file." );
    System.out.println( "Queue Size: " + myQueue.size() );
    System.out.println( "myQueue = " + myQueue.size() );
    QueueDataSource dataSource = new QueueDataSource( myQueue );
    Processor p = null ;
    try{
    System.out.println( "Create processor for QueueDataSource ... " );
    p = Manager.createProcessor( dataSource );
    catch( Exception e ){
    System.err.println( "Cannot create a processor for the QueueDataSource. " );
    System.out.println( "\nProcessor is created." );
    p.addControllerListener( this );
    p.configure();
    if( !waitForState( p, p.Configured ) ) {
    System.err.println( "Failed to configure the processor." );
    System.out.println( "\nProcessor is configured") ;
    // p.setContentDescriptor( new ContentDescriptor( ContentDescriptor.RAW ) );
    p.setContentDescriptor( new ContentDescriptor( FileTypeDescriptor.WAVE ) );
    TrackControl tcs[] = p.getTrackControls();
    Format f[] = tcs[0].getSupportedFormats();
    if( f == null || f.length == 0 ){
    System.err.println( "The mux does not support the input format : "+ tcs[0].getFormat() );
    tcs[0].setFormat(
    new AudioFormat( AudioFormat.ULAW,
    8000,
    8,
    1,
    Format.NOT_SPECIFIED,
    AudioFormat.SIGNED,
    8,
    Format.NOT_SPECIFIED,
    Format.byteArray ) );
    //System.out.println( "Setting the track format to: " + f[4] );
    p.realize();
    if( !waitForState( p, p.Realized )){
    System.err.println( "Failed to realize the processor" );
    DataSink dsink;
    MediaLocator outML = new MediaLocator("file:/c:/media/queue.wav" );
    if( (dsink = createDataSink( p, outML )) == null ){
    System.err.println( "Failed to create a datasink for given " +
    "mediaLocator : " + outML );
    dsink.addDataSinkListener( this );
    System.out.println( "\nProcessor is realized" );
    try{
    p.start();
    dsink.start();
    catch( IOException ioe ){
    System.err.println( "IO error during processing." );
    waitForFileDone();
    try{
    dsink.close();
    catch( Exception e ){
    p.removeControllerListener( this );
    System.err.println( "... done processing." );
    DataSink createDataSink( Processor p, MediaLocator outML ){
    DataSource ds ;
    if( ( ds = p.getDataOutput() ) == null ) {
    System.err.println( "Something is really wrong: the processor does" +
    " not have an output DataSource. " );
    return null;
    System.out.println( "DataOutput: " + ds.getContentType() );
    DataSink dsink;
    try{
    System.out.println( "- create DataSink for : " + outML );
    dsink = Manager.createDataSink( ds, outML );
    dsink.open();
    catch( Exception e ){
    System.err.println( "Cannot create the DataSink: " + e );
    return null;
    return dsink;
    Object waitSync = new Object();
    boolean stateTransitionOK = true;
    boolean waitForState( Processor p, int state ){
    synchronized( waitSync ){
    try{
    while( p.getState() < state && stateTransitionOK )
    waitSync.wait();
    catch( Exception e ){
    return stateTransitionOK;
    public void controllerUpdate(javax.media.ControllerEvent controllerEvent) {
    if( controllerEvent instanceof ConfigureCompleteEvent ||
    controllerEvent instanceof RealizeCompleteEvent ||
    controllerEvent instanceof PrefetchCompleteEvent ){
    synchronized( waitSync ){
    stateTransitionOK = true;
    waitSync.notifyAll();
    } else if( controllerEvent instanceof ResourceUnavailableEvent ){
    synchronized( waitSync ){
    stateTransitionOK = false;
    waitSync.notifyAll( );
    public static void main( String args[] ){
    QueueDataSourceTester tester = new QueueDataSourceTester();
    tester.testIt();
    Object waitFileSync = new Object();
    boolean fileDone = false;
    boolean fileSuccess = true;
    boolean waitForFileDone(){
    synchronized( waitFileSync ){
    try{
    waitFileSync.wait( 5000 );
    catch( Exception e ){
    System.err.println( "Error on waiting file to be done" );
    return fileSuccess;
    public void dataSinkUpdate(javax.media.datasink.DataSinkEvent dataSinkEvent) {
    if( dataSinkEvent instanceof EndOfStreamEvent ){
    synchronized( waitFileSync ){
    fileDone = true;
    waitFileSync.notifyAll();
    else if ( dataSinkEvent instanceof DataSinkErrorEvent ){
    synchronized( waitFileSync ){
    fileDone = true;
    fileSuccess = false;
    waitFileSync.notifyAll();
    // Inner Class
    * A datasource that will read Media data from Queue.
    * Inside queue individual RAW data packats are stored.
    * @author wguo
    public class QueueDataSource extends PullBufferDataSource{
    protected QueueSourceStream streams[];
    /** Creates a new instance of QueueDataSource */
    public QueueDataSource( LinkedList source ) {
    printDebug( "QueueDataSource: QueueDataSource( LinkedList) " );
    streams = new QueueSourceStream[1];
    streams[0] = new QueueSourceStream( source );
    public void connect() throws java.io.IOException {
    printDebug( "QueueDataSource: connect() " );
    public void disconnect() {
    printDebug( "QueueDataSource: disconnect()" );
    public String getContentType() {
    return ContentDescriptor.RAW;
    public Object getControl(String str) {
    printDebug( "QueueDataSource: getControl(String) " );
    return null;
    public Object[] getControls() {
    printDebug( "QueueDataSource: getControls() " );
    return new Object[0];
    public javax.media.Time getDuration() {
    return DURATION_UNKNOWN;
    public javax.media.protocol.PullBufferStream[] getStreams() {
    printDebug( "QueueDataSource: getStreams() " );
    return streams;
    public void start() throws java.io.IOException {
    printDebug( "QueueDataSource:start()" );
    public void stop() throws java.io.IOException {
    printDebug( "QueueDataSource: stop() " );
    private void printDebug( String methodInfo ){
    System.out.println( methodInfo + " is called" );
    // Inner Class
    public class QueueSourceStream implements PullBufferStream{
    LinkedList sourceQueue;
    AudioFormat audioFormat;
    boolean ended = false;
    /** Creates a new instance of QueueSourceStream */
    public QueueSourceStream( LinkedList sourceQueue ) {
    printDebug( "QueueSourceStream: QueueSourceStream( LinkedList )" );
    this.sourceQueue = sourceQueue;
    audioFormat = new AudioFormat(
    AudioFormat.ULAW,
    8000,
    8,
    1,
    Format.NOT_SPECIFIED,
    AudioFormat.SIGNED,
    8,
    Format.NOT_SPECIFIED,
    Format.byteArray);
    public boolean endOfStream() {
    printDebug( "QueueSourceStream: endOfStream()" );
    return ended;
    public javax.media.protocol.ContentDescriptor getContentDescriptor() {
    printDebug( "QueueSourceStream: getContentDescriptor()" );
    return new ContentDescriptor( ContentDescriptor.RAW) ;
    public long getContentLength() {
    printDebug( "QueueSourceStream:getContentLength()" );
    return 0;
    public Object getControl(String str) {
    printDebug( "QueueSourceStream:getControl( String) " );
    return null;
    public Object[] getControls() {
    printDebug( "QueueSourceStream:getControls()" );
    return new Object[0];
    public javax.media.Format getFormat() {
    printDebug( "QueueSourceStream:getFormat()" );
    return audioFormat;
    public void read(javax.media.Buffer buffer) throws java.io.IOException {
    buffer.setData( (byte[])sourceQueue.removeFirst() );
    buffer.setOffset( 0 );
    buffer.setLength( 1024 );
    buffer.setFormat( audioFormat );
    printDebug( "QueueSourceStream: read( Buffer ) " );
    else {
    buffer.setEOM( true );
    buffer.setOffset( 0 );
    buffer.setLength( 0 );
    ended = true;
    System.out.println( "Done reading byte array" );
    return;
    public boolean willReadBlock() {
    printDebug( "QueueSourceStream: willReadBlock()" );
    if( myQueue.isEmpty() )
    return true;
    else
    return false;
    private void printDebug( String methodInfo ){
    System.out.println( methodInfo + " is called. " );

  • Mapping 1D array of sensor data to a 3D graphical model

    does anyone have any ideas how to approach this matter in LabVIEW.
    I have a measurement that is an array of 1D values.
    I would like to display that 1D array of values as points of specific color on a 3D model of some sort.
    What is the best software to create the 3D model, what is the easiest way to map my values to the points on that model.
    Thanks,
    Maciej

    You can use a wrl file with the 3D picture control. How you map your values is optional. I have used color coded sphere at the locations of interest.
    Have fun,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • SelectBooleanCheckbox in Map or Array?

    Hi guys,
    Anybody has example on putting selectBooleanCheckbox in a Map/Array in backing bean so that in JSP page we don't need to put it like 1 by 1. For example, if I got a list of 5 facilities for selectBooleanCheckbox, I don't need to do it like the following in JSP page:
    <h:selectBooleanCheckbox id="facility1" value="#{backingBean.facility1}"/>
    <h:selectBooleanCheckbox id="facility2" value="#{backingBean.facility2}"/>
    <h:selectBooleanCheckbox id="facility3" value="#{backingBean.facility3}"/>
    <h:selectBooleanCheckbox id="facility4" value="#{backingBean.facility4}"/>
    <h:selectBooleanCheckbox id="facility5" value="#{backingBean.facility5}"/>
    where I can just loop thru the boolean[] facility in backing bean will do.
    thanks !

    Try h:dataTable.
    <h:dataTable value="#{backingBean.facilities}" var="item">
    <h:column>
    <h:selectBooleanCheckbox id="check" value="#{item.facility}"/>
    </h:column>
    <h:column>
    <h:outputLabel for="check">
    <h:outputText value="#{item.name}"/>
    </h:outputLabel>
    </h:column>
    </h:dataTable>

  • Java - AS mapping for arrays

    I've got a basic Java -> AS mapping working where my
    server-side Java "Customer" class is serialized down to my
    client-side AS "Customer" object via my use of the RemoteClass
    attribute. But when my Java object returns a Customer[] or a List,
    the items inside the collection revert back to just "Object"'s
    instead of "Customer"'s. Any idea why?
    I'm using RemoteObject.

    Doh! Ok I solved my own problem. This might be a gotcha for
    others. Originally, I had code like this in the result handler for
    my remoteobject:
    var cust:Customer = Customer(event.result);
    But when I was testing returning an array of Customer
    objects, I changed my code to this just to see what was coming
    back:
    ObjectUtil.toString(event.result);
    When I did this, I removed any references to my Customer
    class so it did not get compiled. Once I added in a dummy reference
    to my Customer class, all worked well again.

  • [jdk1.4] What's the pro of using a Buffer against an array?

    Hi all,
    I was studying the new java.nio classes and I have a question:
    what's the main advantage to use a Buffer (let's say an IntBuffer)
    against an array of int ?
    As IntBuffer need to be allocated with the number of elements....
    IntBuffer ib = IntBuffer.allocate(2);
    why not simply using a fast array of int [] rather ?
    Under which circumstances can be useful an IntBuffer?
    thanks
    Francesco

    The latest JDC Tech Tip discusses this briefly. I think the real benefit lies in the fact that the stream can read directly into the buffer so there is no need to read to a buffer, then copy to the array.
    Check out the June 4th Tech Tip. Hope this helps.
    http://developer.java.sun.com/developer/JDCTechTips/

  • DMA RT to FPGA guaranteed order?

    I have a question regarding the sending of data via FIFO to an FPGA card via DMA.  I would assume that if I have several locations in my RT code sending data via DMA FIFO that it is still guaranteed that any given DMA Transfer (let's say 12 data values) are delivered atomically.  That is to say that each DMA node data is sent as a contiguous block.
    Take the following example.  I have two DMA FIFO nodes in parallel.  I don't know which is going to be executed first, and they will most of the time be vying for bandwidth.  Both nodes send over the SAME DMA FIFO.  Does the data arrive interleaved, or is each sent block guaranteed to be contiguous ont he receiving end.  Do I end up with
    Data0 (Faster node)
    Data1 (Faster node)
    Data2 (Faster node)
    Data3 (Faster node)
    Data11 (Faster node)
    Data0 (Slower node)
    Data1 (Slower node)
    Data11 (Slower node)
    or do the individual items get interleaved.
    I'm kind of assuming that they remain in a contiguous block which I'm also hoping for because I want to abuse the DMA FIFO as a built-in timing source for a specific functionality I require on my FPGA board.  I can then use the RT-FPGA DMA Buffer to queue up my commands and still have them execute in perfect determinism (Until the end of the data in my single DMA transfer of course).
    Shane.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

    Woah, new avatar. Confusing! 
    I am going to preface this by saying that I am making assumptions, and in no way is this a definitive answer. In general, I have always had to do FPGA to RT streaming through a FIFO and not the other way around.
    When writing to the FPGA from the RT, does the FIFO.write method accept an array of data as the input? I'm assuming it does. If so, I'd then make the assumption that the node is blocking (like most everything else in LabVIEW). in which case the data would all be queued up contiguously. Interleaving would imply that two parallel writes would have to know about each other, and the program would wait for both writes to execute so that it could interleave the data. That doesn't seem possible (or if it was, this would be an awful design decision because what if one of the writes never executed).
    Of course, this is all assuming that I am understanding what you are asking.
    You're probably safe assuming the blocks are contigous. Can you test this by simulating the FPGA? If your'e really worried about interleaving, could you just wrap the FIFO.write method up in a subVI, that way you are 100% sure of the blocking?
    Edit: Had a thought after I posted, how can you guarantee the order things are written to the FIFO? For example, what if the "slow" write actually executes first? Then your commands, while contiguous, will be "slower node" 1-12 then "faster node" 1-12. It seems to me you would have to serialize the two to ensure anything. 
    Sorry if I'm not fully understanding your question.
    CLA, LabVIEW Versions 2010-2013

  • MD randomly dropping partition from array

    Hello, folks! I am having some trouble with MD randomly removing a partition from one of my RAID-1 arrays. So far this has happened three times over the past couple weeks, but it only happens on boot.
    I have two 3TB WD SATA hard disks containing two RAID-1 volumes set up as follows:
    /dev/sda1 FAT32 EFI System Partition (250MiB)
    /dev/sdb1 Reserved Space (250MiB)
    /dev/sda2 Disk 0 of /dev/md0 with v0.90 metadata (250MiB)
    /dev/sdb2 Disk 1 of /dev/md0 with v0.90 metadata (250MiB)
    /dev/sda3 swap partition 0 encrypted with dm-crypt mapped to /dev/mapper/swapA (8GiB)
    /dev/sdb3 swap partition 1 encrypted with dm-crypt mapped to /dev/mapper/swapB (8GiB)
    /dev/sda4 Disk 0 of /dev/md1 with v1.2 metadata (2750GiB)
    /dev/sdb4 Disk 1 of /dev/md1 with v1.2 metadata (2750GiB)
    /dev/md1 is encrypted with LUKS and mapped to /dev/mapper/root
    /dev/mapper/root is the only volume in the LVM volume group rootvg
    the volume group rootvg currently has three logical volumes
    logical volume root is mapped to /dev/mapper/rootvg-root and is the file system root
    logical volume home is mapped to /dev/mapper/rootvg-home and is mounted /home
    logical volume var is mapped to /dev/mapper/rootvg-var and is mounted /var
    I also wrote this initcpio hook (I call it 'secdec'), with a bit of help from the Arch Wiki, which decrypts /dev/mapper/root, optionally with a openssl encrypted key file on a USB memory stick:
    run_hook ()
    local keyCopyDec keyCopyEnc keyMountPoint maxTries retryDelay \
    shutdownOnFail
    # customizable ############################################################
    keyCopyDec="/crypto_keyfile.bin" # temp storage for decrypted key data
    keyCopyEnc="/crypto_keyfile.enc" # temp storage for encrypted key data
    keyMountPoint="/ckey" # key storage device mount point
    maxTries=3 # max number of decrypt attempts
    retryDelay=2 # delay in seconds between retries
    shutdownOnFail=0 # shut down computer if decrypt fails
    #+0=yes, 1=no
    # /customizable ###########################################################
    local abortMsg passPromptKey passPromptVol passWrong secdecFormat \
    shutdownMsg
    local E_NOFILE
    local KEY NOKEY SSLKEY
    local CSQUIET OIFS
    local cryptDev cryptName keyDev keyFile keyFs keyType pass passPrompt \
    success tries
    abortMsg="Aborting..."
    passPromptKey="Key passphrase: "
    passPromptVol="LUKS passphrase: "
    passWrong="Invalid passphrase."
    secdecFormat="secdec=cryptdev:dmname:keydev:keyfs:keyfile"
    shutdownMsg="Shutting down computer. You may try again later."
    E_NOFILE=66
    KEY=1
    NOKEY=0
    SSLKEY=2
    OIFS=$IFS
    [ "$(echo "${quiet}" | awk '{print tolower($0)}')" == "y" ] && \
    CSQUIET=">/dev/null 2>&1"
    askForBooleanInput ()
    # Ask the user for boolean input.
    # $1: The question to pose.
    # $2: A string containing single characters, separated by spaces, which are
    #+keys pressed that would return boolean true (0).
    # $3: A string containing single characters, separated by spaces, which are
    #+keys pressed that would return a boolean false (1).
    # Returns 0 if the user presses a key that generates a character found in
    #+$2.
    # Returns 1 if the user presses a key that generates a character found in
    #+$3.
    # Returns 2 if an incorrect number of parameters was provided.
    local keyin
    [ ${#} -ne 3 ] && return 2
    echo -n "$1"
    while true; do
    read -sn1 keyin
    case "$keyin" in
    [$2]) echo "$keyin"; keyin=0; break;;
    [$3]) echo "$keyin"; keyin=1; break;;
    *) echo -n -e "\a";;
    esac
    done
    return $keyin
    askForPass ()
    # Ask the user to enter a pass{word|phrase}.
    # $1: The prompt to display.
    # $2: The name of the variable to assign the input pass{word|phrase} to.
    #+For example, to assign to $pass, $2 should be "pass".
    # Returns 0 on success or 1 if there is a parameter error.
    [ ${#} -ne 2 ] || [ -z "${1}" ] || [ -z "${2}" ] && return 1
    read -rsp "$1" "$2"
    echo
    isSsl ()
    # Examine a file for indications that it is SSL encrypted.
    # $1: Path to the key file to examine.
    # Returns 0 if the file appears to be SSL encrypted, 1 if the file does not
    #+appear to be SSL encrypted and $E_NOFILE if $1 is not a regular file.
    [ ! -f "${1}" ] && return $E_NOFILE
    [ "$(dd if="${1}" bs=1 count=8 2>/dev/null | \
    awk '{print tolower($0)}')" == "salted__" ]
    getKey ()
    # Attempt to find and copy a key from $keyDev to $keyCopyEnc.
    # $1: Path to the device containing the key data.
    # $2: Name of file system containing the key file.
    # $3: Path to the key file, relative to $4.
    # $4: Mount point of partition containing key file.
    # $5: Path to temporary copy of key file.
    # $6: Boolean value indicating whether to allow user the opportunity to
    #+switch key devices before attempting to find a key. This is useful if
    #+a key has already been tried and failed. The user could switch memory
    #+devices before trying again. 0=true, 1=false; default is false.
    # Returns one of $KEY, $NOKEY or $SSLKEY depending on what was found.
    local result wait
    if [ -z "${6}" ] || [ ${6} -eq 1 ]; then wait=1; else wait=0; fi
    mkdir -p "$4" >/dev/null 2>&1
    while true; do
    if [ ${wait} -eq 0 ]; then
    askForBooleanInput \
    "(S)earch for key or (R)evert to LUKS passphrase? " "s S" "r R"
    if [ ${?} -eq 0 ]; then result=$KEY; else result=$NOKEY; fi
    wait=1
    else
    result=$KEY
    fi
    if [ ${result} -eq ${KEY} ]; then
    if poll_device "${1}" ${rootdelay}; then
    mount -r -t "$2" "$1" "$4" >/dev/null 2>&1
    dd if="$4/$3" of="$5" >/dev/null 2>&1
    umount "$4" >/dev/null 2>&1
    if [ -f "${5}" ]; then
    isSsl "${5}" && result=$SSLKEY
    else
    err "Key $3 not found."
    unset result
    wait=0
    fi
    else
    err "Key device $1 not found."
    unset result
    wait=0
    fi
    fi
    [ -n "${result}" ] && break
    done
    return $result
    # If the secdec kernel parameter was not specified, inform the user, but
    #+allow init to continue in case another hook will work.
    if [ -z "${secdec}" ]; then
    echo "Missing parameter: $secdecFormat"
    return 0
    fi
    # Make sure required kernel modules are available.
    if ! /sbin/modprobe -a -q dm-crypt >/dev/null 2>&1 || \
    [ ! -e "/sys/class/misc/device-mapper" ]; then
    err "Required kernel modules not available."
    err "$abortMsg"
    exit 1
    fi
    if [ ! -e "/dev/mapper/control" ]; then
    mkdir -p "/dev/mapper" >/dev/null 2>&1
    mknod "/dev/mapper/control" c \
    $(cat /sys/class/misc/device-mapper/dev | sed 's|:| |') >/dev/null 2>&1
    fi
    # Parse the secdec kernel parameter, check it's format, make sure $cryptDev
    #+is available, and that it contains a LUKS volume.
    IFS=:
    read cryptDev cryptName keyDev keyFs keyFile <<EOF
    $secdec
    EOF
    IFS=$OIFS
    if [ $(echo "${secdec}" | awk -F: '{print NF}') -ne 5 ] || \
    [ -z "${cryptDev}" ] || [ -z "${cryptName}" ]; then
    err "Verify parameter format: $secdecFormat"
    err "$abortMsg"
    exit 1
    fi
    if ! poll_device "${cryptDev}" ${rootdelay}; then
    err "Device $cryptDev not available."
    err "$abortMsg"
    exit 1
    fi
    # Inform the user that $cryptDev doesn't contain a LUKS volume, but allow
    #+init to continue, in case another hook can handle this.
    if ! /sbin/cryptsetup isLuks "${cryptDev}" >/dev/null 2>&1; then
    echo "Device $cryptDev does not contain a LUKS volume."
    return 0
    fi
    # Attempt to open the LUKS volume.
    tries=0
    unset keyType
    while true; do
    success=1
    # Attempt to copy a decryption key.
    if [ -z ${keyType} ]; then
    getKey "$keyDev" "$keyFs" "$keyFile" "$keyMountPoint" \
    "$keyCopyEnc" 1
    keyType=$?
    elif [ ${keyType} -eq ${KEY} ]; then
    getKey "$keyDev" "$keyFs" "$keyFile" "$keyMountPoint" \
    "$keyCopyEnc" 0
    keyType=$?
    elif [ ${keyType} -eq ${SSLKEY} ]; then
    if askForBooleanInput "(U)se a different key or (T)ry again? " \
    "u U" "t T"; then
    getKey "$keyDev" "$keyFs" "$keyFile" "$keyMountPoint" \
    "$keyCopyEnc" 0
    keyType=$?
    fi
    fi
    # Open the LUKS volume.
    if [ ${keyType} -eq ${NOKEY} ]; then
    askForPass "$passPromptVol" "pass"
    /sbin/cryptsetup luksOpen "$cryptDev" "$cryptName" "$CSQUIET" <<EOF
    $pass
    EOF
    success=$?
    [ ${success} -ne 0 ] && err "$passWrong"
    else
    if [ ${keyType} -eq ${SSLKEY} ]; then
    askForPass "$passPromptKey" "pass"
    /sbin/openssl aes256 -pass pass:"$pass" -d -in "$keyCopyEnc" \
    -out "$keyCopyDec" >/dev/null 2>&1
    if [ ${?} -ne 0 ]; then
    rm -f "$keyCopyDec" >/dev/null 2>&1
    err "$passWrong"
    fi
    else
    mv "$keyCopyEnc" "$keyCopyDec" >/dev/null 2>&1
    fi
    if [ -f "${keyCopyDec}" ]; then
    /sbin/cryptsetup --key-file "$keyCopyDec" \
    luksOpen "$cryptDev" "$cryptName" "$CSQUIET"
    success=$?
    fi
    fi
    [ ${success} -ne 0 ] && err "Failed to open LUKS volume."
    tries=$(( $tries + 1 ))
    [ ${tries} -ge ${maxTries} ] || [ ${success} -eq 0 ] && break
    sleep "$retryDelay"
    done
    if [ ${success} -eq 0 ]; then
    if [ ! -e "/dev/mapper/${cryptName}" ]; then
    err "LUKS volume was opened, but failed to map to $cryptName."
    err "$abortMsg"
    exit 1
    fi
    echo "LUKS volume opened."
    else
    if [ ${shutdownOnFail} -eq 0 ]; then
    echo "shutdownMsg"
    poweroff -f
    fi
    exit 1
    fi
    The failing array is /dev/md1 and mdadm is reporting the following:
    mdadm --detail /dev/md1
    /dev/md1:
    Version : 1.2
    Creation Time : Wed May 30 18:50:05 2012
    Raid Level : raid1
    Array Size : 2921467179 (2786.13 GiB 2991.58 GB)
    Used Dev Size : 2921467179 (2786.13 GiB 2991.58 GB)
    Raid Devices : 2
    Total Devices : 1
    Persistence : Superblock is persistent
    Update Time : Wed Sep 12 03:34:52 2012
    State : clean, degraded
    Active Devices : 1
    Working Devices : 1
    Failed Devices : 0
    Spare Devices : 0
    Name : archiso:1
    UUID : 8ad37e84:f7261906:da3d317e:24080362
    Events : 44661
    Number Major Minor RaidDevice State
    0 8 4 0 active sync /dev/sda4
    1 0 0 1 removed
    mdadm --examine /dev/sda4
    /dev/sda4:
    Magic : a92b4efc
    Version : 1.2
    Feature Map : 0x0
    Array UUID : 8ad37e84:f7261906:da3d317e:24080362
    Name : archiso:1
    Creation Time : Wed May 30 18:50:05 2012
    Raid Level : raid1
    Raid Devices : 2
    Avail Dev Size : 5842934631 (2786.13 GiB 2991.58 GB)
    Array Size : 2921467179 (2786.13 GiB 2991.58 GB)
    Used Dev Size : 5842934358 (2786.13 GiB 2991.58 GB)
    Data Offset : 2048 sectors
    Super Offset : 8 sectors
    State : clean
    Device UUID : abba1dc3:3fadf7a7:be452bb5:b8bbe97b
    Update Time : Wed Sep 12 03:37:48 2012
    Checksum : aad3e44b - correct
    Events : 44729
    Device Role : Active device 0
    Array State : A. ('A' == active, '.' == missing)
    mdadm --examine /dev/sdb4/dev/sdb4:
    Magic : a92b4efc
    Version : 1.2
    Feature Map : 0x0
    Array UUID : 8ad37e84:f7261906:da3d317e:24080362
    Name : archiso:1
    Creation Time : Wed May 30 18:50:05 2012
    Raid Level : raid1
    Raid Devices : 2
    Avail Dev Size : 5842934631 (2786.13 GiB 2991.58 GB)
    Array Size : 2921467179 (2786.13 GiB 2991.58 GB)
    Used Dev Size : 5842934358 (2786.13 GiB 2991.58 GB)
    Data Offset : 2048 sectors
    Super Offset : 8 sectors
    State : clean
    Device UUID : 09a09f49:b329feaa:3341111b:47b484fe
    Update Time : Wed Sep 12 01:50:34 2012
    Checksum : 1cdc19c0 - correct
    Events : 42869
    Device Role : Active device 1
    Array State : AA ('A' == active, '.' == missing)
    cat /proc/mdstat
    Personalities : [raid1]
    md0 : active raid1 sda2[0] sdb2[1]
    204736 blocks [2/2] [UU]
    md1 : active raid1 sda4[0]
    2921467179 blocks super 1.2 [2/1] [U_]
    unused devices: <none>
    This is md log info of the first reboot after my first recovery:
    Sep 9 20:18:03 localhost kernel: [ 1.784225] md: raid1 personality registered for level 1
    Sep 9 20:18:03 localhost kernel: [ 2.552971] md: md1 stopped.
    Sep 9 20:18:03 localhost kernel: [ 2.553418] md: bind<sdb4>
    Sep 9 20:18:03 localhost kernel: [ 2.553574] md: bind<sda4>
    Sep 9 20:18:03 localhost kernel: [ 2.554080] md/raid1:md1: active with 2 out of 2 mirrors
    Sep 9 20:18:03 localhost kernel: [ 2.554093] md1: detected capacity change from 0 to 2991582391296
    Sep 9 20:18:03 localhost kernel: [ 2.566266] md1: unknown partition table
    Sep 9 20:18:03 localhost kernel: [ 2.617922] md: md0 stopped.
    Sep 9 20:18:03 localhost kernel: [ 2.618382] md: bind<sdb2>
    Sep 9 20:18:03 localhost kernel: [ 2.618525] md: bind<sda2>
    Sep 9 20:18:03 localhost kernel: [ 2.619175] md/raid1:md0: active with 2 out of 2 mirrors
    Sep 9 20:18:03 localhost kernel: [ 2.619203] md0: detected capacity change from 0 to 209649664
    Sep 9 20:18:03 localhost kernel: [ 10.933334] md0: unknown partition table
    And this is the next time I rebooted:
    Sep 10 19:59:07 localhost kernel: [ 1.780481] md: raid1 personality registered for level 1
    Sep 10 19:59:07 localhost kernel: [ 2.806037] md: md1 stopped.
    Sep 10 19:59:07 localhost kernel: [ 2.806345] md: bind<sda4>
    Sep 10 19:59:07 localhost kernel: [ 2.806888] md/raid1:md1: active with 1 out of 2 mirrors
    Sep 10 19:59:07 localhost kernel: [ 2.806898] md1: detected capacity change from 0 to 2991582391296
    Sep 10 19:59:07 localhost kernel: [ 2.820308] md1: unknown partition table
    Sep 10 19:59:07 localhost kernel: [ 2.956599] md: md0 stopped.
    Sep 10 19:59:07 localhost kernel: [ 2.957149] md: bind<sdb2>
    Sep 10 19:59:07 localhost kernel: [ 2.957269] md: bind<sda2>
    Sep 10 19:59:07 localhost kernel: [ 2.958086] md/raid1:md0: active with 2 out of 2 mirrors
    Sep 10 19:59:07 localhost kernel: [ 2.958100] md0: detected capacity change from 0 to 209649664
    Sep 10 19:59:07 localhost kernel: [ 11.742281] md0: unknown partition table
    In between these two boots there are no reports of md failures. For some reason, its just dropping the second partition.
    I just did a restoration earlier today and on the very next boot, md refuses to use /dev/sdb4. Once I booted, I checked update times (not the ones listed) and /dev/sda4 and /dev/sdb4 were about 4 minutes apart. Since it takes only about a minute for Arch to reboot, including me typing my openssl key password, Arch was running for about 3 minutes without updating. I'm assuming this is of some significance since /dev/md0 reports perfect synchronization.
    All of this has been working very well for me for about 6 months now. Both hard drives, which I bought at the same time, are about 9 months old. I checked both drives using smartctl, and both report SMART enabled and passed. SMART attribute data doesn't make a lot of sense to me and I haven't looked up the format, but the reallocation event value is the same as the day I bought the drives, so I'm kind of assuming things are ok there, or at least bad sectors aren't being created.
    I hope I've provided all required details here. Any help would be appreciated.
    Last edited by cng1024 (2012-09-13 00:02:43)

    It would seem that nobody has any ideas about why this may be happening. I've done a complete diagnostic of both hard disks and both passed. I then downloaded the latest iso, formatted and reinstalled, but that failed after one reboot.
    I have a theory as to why it may be happening, but I haven't tested it yet. Perhaps someone can tell me if I may be on the right track here. I got to wondering what happens during shutdown. The root fs remounts ro during shutdown, but it does remain mounted which means everything under that, my logical volumes, LUKS and RAID are all still open when the system halts. I saved my original configs before I reformatted and it turns out I forgot to add the shutdown hook to the initcpio image which means my RAID wasn't being stopped before halt.
    I'm going to try a few experiments to see if adding the shutdown hook makes a difference. Hopefully I'm right, and I'll update either way, but I'd still appreciate it if someone with a bit more experience could weigh in on this.

  • M-Series Buffered Event Counting with DMA -- gating problem

    Hi --
    I am implementing DMA-based buffered event counting on a PCIe-6259 board.  I use G0_Out as the gate for G1, which counts events on a PFI pin.   So by setting the speed of G0, I get an event count (either cumulative or non-cumulative) on a periodic basis, which is directly DMA'd to my buffer, and synchronized with other i/o operations.
    This is working well right now, except for one problem, which is that the I only get data if there is at least one  source edge between gates.  i.e. if there are no edges, nothing gets pumped to the dma buffer.
    I am guessing that a stale data error is somehow choking off the DMA transfer from the counter.   Is that possible?
    Is there some magic that I need to do to avoid this, because for this application, especially if I am counting cumulatively, I don't care about a missing edge, but I do care if the dma transfers get out of phase with the rest of my timing.
    Thanks in advance for any help!
    --spg
    Here is a snippet of the code that sets up the event counting on G1, partly based on gpctex6.cpp:
    const int sDMASelect[] = {1,2,4,8,3,5};
    // source:  pfi, or -1 for 20Khz clock
    void eventTimerSetup(tMSeries *board, tTIO *tio, int dmaChannel, bool cumulative, int source)
        int sourceSelect = (source==-1) ? 0 : (source+1);
        //MSeries.CTR.Source
        tio->G1_Input_Select.setG1_Source_Select(sourceSe​lect); // (pfi+1) or 20Khz=0
        tio->G1_Input_Select.setG1_Source_Polarity(0); //rising=0
        tio->G1_Input_Select.setG1_OR_Gate(0);
        tio->G1_Input_Select.flush();
        //MSeries.CTR.Gate
        tio->G1_Input_Select.setG1_Gate_Select(20); //the G_OUT signal from other clock=20
        tio->G1_Input_Select.setG1_Output_Polarity(0); //active high=0
        tio->G1_Input_Select.flush();
        //MSeries.CTR.IncrementRegisters
        tio->G1_AutoIncrement.writeRegister(0);
        //MSeries.CTR.InitialCountRegisters
        tio->G1_Mode.writeG1_Load_Source_Select(tTIO::tG1​_Mode::kG1_Load_Source_SelectLoad_A);
        tio->G1_Load_A.writeRegister(0);
        tio->G1_Command.writeG1_Load(1);
        tio->G1_Load_B.writeRegister(0);
        tio->G1_Load_A.writeRegister(0);
        tio->G1_Command.setG1_Bank_Switch_Enable(tTIO::tG​1_Command::kG1_Bank_Switch_EnableBank_X);
        tio->G1_Command.setG1_Bank_Switch_Mode(tTIO::tG1_​Command::kG1_Bank_Switch_ModeGate);
        tio->G1_Command.flush();
        //MSeries.CTR.ApplicationRegisters
        tio->G1_Input_Select.setG1_Gate_Select_Load_Sourc​e(0);
        tio->G1_Mode.setG1_Reload_Source_Switching(tTIO::​tG1_Mode::kG1_Reload_Source_SwitchingAlternate);
        tio->G1_Mode.setG1_Loading_On_Gate(cumulative ? tTIO::tG1_Mode::kG1_Loading_On_GateNo_Reload : tTIO::tG1_Mode::kG1_Loading_On_GateReload_On_Stop_​Gate);
        tio->G1_Mode.setG1_Loading_On_TC(tTIO::tG1_Mode::​kG1_Loading_On_TCRollover_On_TC);
        tio->G1_Mode.setG1_Gating_Mode (tTIO::tG1_Mode::kG1_Gating_ModeEdge_Gating_Active​_High);
        tio->G1_Mode.setG1_Gate_On_Both_Edges (tTIO::tG1_Mode::kG1_Gate_On_Both_EdgesBoth_Edges_​Disabled);
        tio->G1_Mode.setG1_Trigger_Mode_For_Edge_Gate(tTI​O::tG1_Mode::kG1_Trigger_Mode_For_Edge_GateGate_Do​es_Not_Stop);
        tio->G1_Mode.setG1_Stop_Mode(tTIO::tG1_Mode::kG1_​Stop_ModeStop_On_Gate);
        tio->G1_Mode.setG1_Counting_Once(tTIO::tG1_Mode::​kG1_Counting_OnceNo_HW_Disarm);
        tio->G1_Second_Gate.setG1_Second_Gate_Gating_Mode​(0);
        tio->G1_Input_Select.flush();
        tio->G1_Mode.flush();
        tio->G1_Second_Gate.flush();
        //MSeries.CTR.UpDown.Registers
        tio->G1_Command.writeG1_Up_Down(tTIO::tG1_Command​::kG1_Up_DownSoftware_Up); //kG1_Up_DownSoftware_Down
        //MSeries.CTR.OutputRegisters
        tio->G1_Mode.writeG1_Output_Mode(tTIO::tG1_Mode::​kG1_Output_ModePulse);
        tio->G1_Input_Select.writeG1_Output_Polarity(0);
        //MSeries.CTR.BufferEnable
        board->G1_DMA_Config.writeG1_DMA_Reset(1);
        board->G1_DMA_Config.setG1_DMA_Write(0);  
        board->G1_DMA_Config.setG1_DMA_Int_Enable(0);
        board->G1_DMA_Config.setG1_DMA_Enable(1);   
        board->G1_DMA_Config.flush();
        tio->G1_Counting_Mode.setG1_Encoder_Counting_Mode​(0);
        tio->G1_Counting_Mode.setG1_Alternate_Synchroniza​tion(0);
        tio->G1_Counting_Mode.flush();
        //MSeries.CTR.EnableOutput
        //board->Analog_Trigger_Etc.setGPFO_1_Output_Enab​le(tMSeries::tAnalog_Trigger_Etc::kGPFO_1_Output_E​nableOutput);
        //board->Analog_Trigger_Etc.setGPFO_1_Output_Sele​ct(tMSeries::tAnalog_Trigger_Etc::kGPFO_1_Output_S​electG_OUT);
        //board->Analog_Trigger_Etc.flush();
        //MSeries.CTR.StartTriggerRegisters
        tio->G1_MSeries_Counting_Mode.writeG1_MSeries_HW_​Arm_Enable(0);    
        board->G0_G1_Select.writeG1_DMA_Select(sDMASelect​[dmaChannel]);   
        tio->G1_Command.writeG1_Arm(1); // arm it
    Scott Gillespie
    http://www.appliedbrain.com
    scott gillespie
    applied brain, inc.
    Solved!
    Go to Solution.

    Okay, I have it working now.  In addition to your suggested changes, I had to remove the following line:
    tio->G1_MSeries_Counting_Mode.writeG1_MSeries_HW_A​rm_Enable(0);    
    It appears that writing something to MSeries_Counting_Mode causes that register to supersede the Counting_Mode register.  Is that right?
    So code that now works for  me is listed below.
    thanks Tom!
    -spg
    void eventCounterSetup(tMSeries *board, tTIO *tio, int dmaChannel, bool cumulative, int source) // pfi, or -1 for 20Khz clock
    int sourceSelect = (source==-1) ? 0 : (source+1);
    //MSeries.CTR.Source
    tio->G1_Input_Select.setG1_Source_Select(sourceSel​ect); // (pfi+1) or 20Khz=0
    tio->G1_Input_Select.setG1_Source_Polarity(0); //rising=0
    tio->G1_Input_Select.setG1_OR_Gate(0);
    tio->G1_Input_Select.flush();
    //MSeries.CTR.Gate
    tio->G1_Input_Select.setG1_Gate_Select(20); //the G_OUT signal from other clock=20
    tio->G1_Input_Select.setG1_Output_Polarity(0); //active high=0
    tio->G1_Input_Select.flush();
    //MSeries.CTR.IncrementRegisters
    tio->G1_AutoIncrement.writeRegister(0);
    //MSeries.CTR.InitialCountRegisters
    tio->G1_Mode.writeG1_Load_Source_Select(tTIO::tG1_​Mode::kG1_Load_Source_SelectLoad_A);
    tio->G1_Load_A.writeRegister(0);
    tio->G1_Command.writeG1_Load(1);
    tio->G1_Load_B.writeRegister(0);
    tio->G1_Load_A.writeRegister(0);
    tio->G1_Command.setG1_Bank_Switch_Enable(tTIO::tG1​_Command::kG1_Bank_Switch_EnableBank_X);
    tio->G1_Command.setG1_Bank_Switch_Mode(tTIO::tG1_C​ommand::kG1_Bank_Switch_ModeGate);
    tio->G1_Command.flush();
    //MSeries.CTR.ApplicationRegisters
    tio->G1_Input_Select.setG1_Gate_Select_Load_Source​(0);
    tio->G1_Mode.setG1_Reload_Source_Switching(tTIO::t​G1_Mode::kG1_Reload_Source_SwitchingAlternate);
    tio->G1_Mode.setG1_Loading_On_Gate(cumulative ? tTIO::tG1_Mode::kG1_Loading_On_GateNo_Reload : tTIO::tG1_Mode::kG1_Loading_On_GateReload_On_Stop_​Gate);
    tio->G1_Mode.setG1_Loading_On_TC(tTIO::tG1_Mode::k​G1_Loading_On_TCRollover_On_TC);
    tio->G1_Mode.setG1_Gating_Mode (tTIO::tG1_Mode::kG1_Gating_ModeEdge_Gating_Active​_High);
    tio->G1_Mode.setG1_Gate_On_Both_Edges (tTIO::tG1_Mode::kG1_Gate_On_Both_EdgesBoth_Edges_​Disabled);
    tio->G1_Mode.setG1_Trigger_Mode_For_Edge_Gate(tTIO​::tG1_Mode::kG1_Trigger_Mode_For_Edge_GateGate_Doe​s_Not_Stop);
    tio->G1_Mode.setG1_Stop_Mode(tTIO::tG1_Mode::kG1_S​top_ModeStop_On_Gate);
    tio->G1_Mode.setG1_Counting_Once(tTIO::tG1_Mode::k​G1_Counting_OnceNo_HW_Disarm);
    tio->G1_Second_Gate.setG1_Second_Gate_Gating_Mode(​0);
    tio->G1_Input_Select.flush();
    tio->G1_Mode.flush();
    tio->G1_Second_Gate.flush();
    //MSeries.CTR.UpDown.Registers
    tio->G1_Command.writeG1_Up_Down(tTIO::tG1_Command:​:kG1_Up_DownSoftware_Up); //kG1_Up_DownSoftware_Down
    //MSeries.CTR.OutputRegisters
    tio->G1_Mode.writeG1_Output_Mode(tTIO::tG1_Mode::k​G1_Output_ModePulse);
    tio->G1_Input_Select.writeG1_Output_Polarity(0);
    //MSeries.CTR.BufferEnable
    board->G1_DMA_Config.writeG1_DMA_Reset(1);
    board->G1_DMA_Config.setG1_DMA_Write(0);  
    board->G1_DMA_Config.setG1_DMA_Int_Enable(0);
    board->G1_DMA_Config.setG1_DMA_Enable(1);   
    board->G1_DMA_Config.flush();
    // from Tom:
    // The "magic" you need is referred to as synchronous counting mode (or Duplicate Count Prevention in NI-DAQmx).  
    // Try setting G1_Encoder_Counting_Mode to 6 (synchronous source mode) and G1_Alternate_Synchronization to 1 (enabled).
    tio->G1_Counting_Mode.setG1_Encoder_Counting_Mode(​6); // 0
    tio->G1_Counting_Mode.setG1_Alternate_Synchronizat​ion(1); // 0
    tio->G1_Counting_Mode.flush();
    board->G0_G1_Select.writeG1_DMA_Select(sDMASelect[​dmaChannel]);   
    tio->G1_Command.writeG1_Arm(1); // arm it
    scott gillespie
    applied brain, inc.

  • How i can get a array in the current page?

    Can i send a array parameters from previous page to current page?
    the coding like below:
    // the coding in the previous page
    String[] strSend = {"a", "b", "c"};
    HashMap map = new HashMap(2);
    map.put("array", strSend);
    pageContext.setForwardURL(
    "OA.jsp?OAFunc=XXFMSRHISQF",
    null,
    KEEP_MENU_CONTEXT,
    null,
    map,
    true,
    ADD_BREAD_CRUMB_NO,
    IGNORE_MESSAGES );
    //the coding in the processRequest of the current pageCO.
    String strParam = pageContext.getParameter("array");
    the problem is that the type of "strParam" is a String.
    it's not a array of String. So it is not the parameter what i need.
    can u tell me how to get the array parameter from previous page. thanks.

    This cannot be achieved directly while using the setForwardURL method, all values that are there in the Hashmap will be appended when the redirection is done, so you cannot get the values that are there in the array object directly.
    Workaround that I can think of, put all the array values in a String object, appended by a delimiter, in the second page, after you do a getParameter(String), recover the values using a StringTokenizer and the delimiter that you used while appending the string values and store the values in a Array.
    Thanks
    Tapash

Maybe you are looking for