[Solved] systemd-user-session: Best way to pass global ENV vars?

Hey guys,
So when using the [email protected] from the user-session-units what's the best / cleanest way to set global environment variables for that systemd --user instance (and thus, all programs spawned from it)?
What I'm talking about is /etc/profile and $HOME/.profile.
For example, I usally configure my XDG_CONFIG_HOME and XDG_CACHE_HOME in my ~/.profile. But since systemd --user is being started by systemd --session none of these environment variables are loaded.
The solution I've come up is to change the ExecStart in the [email protected] file to something like this:
ExecStart=/usr/bin/sh -c "source /etc/profile; source $HOME/.config/bash/environment; exec /usr/lib/systemd/systemd --user"
I know I could use the `EnvironmentFile` option to load the environment variables from a file, but it's not as flexable as a bash script.
Am I thinking about this problem wrong? Is there a more "systemd --user"-y way of solving the problem?
Last edited by EvanPurkhiser (2013-08-12 03:02:48)

I've more or less solved this using my own user-session units. I still don't know if my method would really be considered the proper way or not though.
Last edited by EvanPurkhiser (2013-08-12 03:02:19)

Similar Messages

  • [SOLVED] Question about systemd-user-session

    Hi!
    I'm trying to setup a systemd --user session (using user-session-units and xorg-launch-helper from aur).
    I have a couple of questions; this is my .xinitrc now:
    #!/bin/bash
    export BROWSER=chromium
    if [ -d /etc/X11/xinit/xinitrc.d ]; then
    for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
    done
    unset f
    fi
    spacefm --desktop &
    compton -cGCf -m 0.9 -i 0.8 -D 5 --shadow-exclude 'g:e:Conky' &
    volumeicon &
    /home/federico/Script/touchpadoff_onboot.sh &
    #connman-ui-gtk &
    /home/federico/Script/calised-script &
    dimdaemon &
    tint2 -c .config/tint2/dragonauta.tint2rc &
    conky -p 5 -c Script/conky.conf &
    exec openbox
    1) is "if" statement required when using systemd-user-session? And if yes, how can I reproduce it?
    2) "conky -p 5 " will wait 5 seconds doing nothing. Will this mean that other .service will wait for it to finish? (i guess no, since they're executed in parallel).
    3) how can I export "chromium" as my default browser?
    Thank you very much!
    Last edited by nierro (2013-04-06 17:56:17)

    I followed everything in that wiki, and in KaiSforza and sofar github page.
    I finally managed to get my old method (autologin to vt and autostart x) to work together with systemd --user: i put in .xinitrc "systemd --user" and deleted everything else.
    So, my .config/systemd/user/ works. The problem is in the [email protected], i guess. I configured it like wiki says, mind to post here your /etc/systemd/system/[email protected]?
    Thanks.
    EDIT: here it is my [email protected]:
    # This file is part of systemd.
    # systemd is free software; you can redistribute it and/or modify it
    # under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 2 of the License, or
    # (at your option) any later version.
    [Unit]
    Description=User Manager for %I
    After=systemd-user-sessions.service
    # This is needed for folks running Xorg on vt/1
    Conflicts=[email protected]
    [Service]
    User=%I
    PAMName=login
    # Note memory:/ required kernel memory CGroups support
    ControlGroup=%R/user/%I/shared cpu:/ memory:/
    ControlGroupModify=yes
    Type=notify
    TTYPath=/dev/tty1
    ExecStart=-/usr/lib/systemd/systemd --user
    Environment=DISPLAY=:0
    Environment=XDG_RUNTIME_DIR=/run/user/%U
    Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%U/dbus/user_bus_socket
    [Install]
    WantedBy=getty.target
    and loginctl says my user has "1000" as UID.
    Last edited by nierro (2013-04-05 16:13:14)

  • Please Suggest best way to pass Strings in a pipeline

    I'm working in a project in which a line passes in a pipeline kind of situation.
    The String is passed between different modules and each module adds some more data to it (or may even remove some of it).
    Which is the best way to pass the String? I think java.lang.String might not be an efficient method because the String i'll be passing will be modified many times.
    Thanx

    Yes. StringBuffer or StringBuilder you can use.
    String string = "test";
    StringBuffer sb = new StringBuffer(string);later you will add some more strings to the StringBuffer
    sb.append("Hello World");No additiional String object will be created.

  • Best way to pass data sets to another program

    Hey
    I want to connect another (maths) program with my java application. Therefore I need to paste data (some kind of tab separated table) to this program.
    I try now to save these data in a separate newly generated file and to pass a command with Java's Runtime.exec() method to this program to read these data. Is this a good idea or might there be better ways?
    If I do so, is there a way in Java to generate some kind of a "temporary" file which will be deleted automatically after usage or is this nothing else than to save it in a common file and delete it afterwards. What's the best way to pass data generally?

    Well, the connection will not be over a network, so I'd rather think it's not a Socket or RMI problem (unless someone convinces me).
    Yes it's very external, it's a C or C++ written program, I don't have any source codes. So far I generated a file for Input command and data, I passed that on to the maths program and returned the output into another file.
    Now I would like to separate the output and like to obtain some tables and graphical things like charts at the output. Do I have to generate three different types of outputfiles? How to store some graphics e.g. some distributions. I thought even of generating a database. I never thought about XML, I don't know if this works for that kind of problem?!

  • Forward systemd's sleep.target to a systemd user session

    My naive approach was the following:
    [email protected]
    [Unit]
    Description=sleep.target of a systemd user session
    Before=sleep.target
    StopWhenUnneeded=yes
    [Service]
    Type=oneshot
    User=%I
    RemainAfterExit=yes
    ExecStart=/usr/bin/systemctl --user start sleep.target
    ExecStop=/usr/bin/systemctl --user stop sleep.target
    [Install]
    WantedBy=sleep.target
    sleep.target
    [Unit]
    Description=Sleep Timer Target
    StopWhenUnneeded=yes
    Unfortunately I got the following error:
    $ systemctl status user-sleep@joerg
    [email protected] - sleep.target of a systemd user session
    Loaded: loaded (/etc/systemd/system/[email protected]; enabled)
    Active: failed (Result: exit-code) since Mo 2013-06-10 12:30:41 CEST; 43min ago
    Process: 10503 ExecStart=/usr/bin/systemctl --user start sleep.target (code=exited, status=1/FAILURE)
    Jun 10 12:30:41 turing-machine systemd[1]: Service [email protected] is not needed anymore. Stopping.
    Jun 10 12:30:41 turing-machine systemd[1]: [email protected]: main process exited, code=exited, status=1/FAILURE
    Jun 10 12:30:41 turing-machine systemd[1]: Failed to start sleep.target of a systemd user session.
    Jun 10 12:30:41 turing-machine systemd[1]: Unit [email protected] entered failed state.
    Can I use "systemctl --user" only at a login shell and not in a systemd unit? Because using "systemd --user" from tty works great.
    My use case is to logout gajim before suspend. This cannot be done in a normal .service file, because it does require a connection to the current dbus session.

    My naive approach was the following:
    [email protected]
    [Unit]
    Description=sleep.target of a systemd user session
    Before=sleep.target
    StopWhenUnneeded=yes
    [Service]
    Type=oneshot
    User=%I
    RemainAfterExit=yes
    ExecStart=/usr/bin/systemctl --user start sleep.target
    ExecStop=/usr/bin/systemctl --user stop sleep.target
    [Install]
    WantedBy=sleep.target
    sleep.target
    [Unit]
    Description=Sleep Timer Target
    StopWhenUnneeded=yes
    Unfortunately I got the following error:
    $ systemctl status user-sleep@joerg
    [email protected] - sleep.target of a systemd user session
    Loaded: loaded (/etc/systemd/system/[email protected]; enabled)
    Active: failed (Result: exit-code) since Mo 2013-06-10 12:30:41 CEST; 43min ago
    Process: 10503 ExecStart=/usr/bin/systemctl --user start sleep.target (code=exited, status=1/FAILURE)
    Jun 10 12:30:41 turing-machine systemd[1]: Service [email protected] is not needed anymore. Stopping.
    Jun 10 12:30:41 turing-machine systemd[1]: [email protected]: main process exited, code=exited, status=1/FAILURE
    Jun 10 12:30:41 turing-machine systemd[1]: Failed to start sleep.target of a systemd user session.
    Jun 10 12:30:41 turing-machine systemd[1]: Unit [email protected] entered failed state.
    Can I use "systemctl --user" only at a login shell and not in a systemd unit? Because using "systemd --user" from tty works great.
    My use case is to logout gajim before suspend. This cannot be done in a normal .service file, because it does require a connection to the current dbus session.

  • Best way to set global environment variables?

    What is the best way to set global (i.e. for all users of the computer, ideally all shells as well) environment variables under Leopard?
    I know that they can be set via ~/.bashrc, ~/.profile or in my case ~/.zshrc files in the terminal on a per user basis.
    Also, they can be set for GUI apps as well via ~/.MacOSX/environment.plist on a per user basis.
    http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Artic les/EnvironmentVars.html
    The path can apparently be set globally by adding files to /etc/paths.d/*
    http://blog.plotdevice.org/2008/04/global-path-in-mac-os-x-leopard/
    Is there a way to set environment variables globally so that they are accessible to all users and all programs including nonstandard shells like zsh?
    My inclination is to set them in /etc/rc.common but that seems like it might be a bad idea. I'd prefer something more like the /etc/paths.d/* solution that only involves adding files, not modifying existing ones. They should be less likely to be overwritten in a system update later.

    They may be less likely to be overwritten than you fear. A lot of things depend on modifications to the system scripts like /etc/profile. Although I'd expect these to be broken by an upgrade to Leopard, for example, they have survived all Tiger upgrades on my machine. You could always have them source scripts in /usr/local, say, so that the work involved in reconfiguring them if they are overwritten is minimal. (Or you could just install your versions in /usr/local and make the system scripts symlinks to those versions - if anything is overwritten, it would be the symlink rather than the file itself. An automated start up script could even check and recreate the symlink if necessary.)
    - cfr

  • Best way to pass an array of waveforms inbetween VIs

    In my VI I am developing I have multiple data sources that output a single waveform. I group these waveforms togeather to make a wave form array. The user selects which waveform they would like to display and they are displayed on a graph on a different form. Right now I have each different graph VI generating the whole array and displaying the selected element.
    My question is, this seems to be not efficent because I am generating data in 3 spots. I would think it would be better to generate it in one spot and then pass only the need data to the three graph VIs. What is the best way todo this? A global variable? Queue? Any suggestions?

    You're probably tired of hearing me say this, but the global function idea is the best.
    A global variable makes a COPY of the data each time you read it. That takes time, and memory. If each of 3 window reads the global, and picks out a channel, then you've made 3 copies of the original data. Depending on your data size, that may or may not be a problem.
    A queue means that once you read the data, it's lost from the queue. If window A reads from the queue, that data chunk is not in the queue any longer, so Window B can't read that same data.
    If the main window generates the data and deposits it in a global function, then each window can ask the global function for a specific channel to display.
    DATA STORAGE.vi:
    Inputs:
    WRITE/read (bool
    ean)
    DATA IN (2-D array of DBL, for example)
    Channel Index (I32)
    Outputs:
    DATA OUT: 1-D array of DBL (or waveform, maybe).
    Code:
    WHILE
    If WRITE/read
    Store DATA IN in a shift reg.
    else
    Pass Shift reg IN to Shift reg Out.
    Pick out channel via CHANNEL INDEX
    Pass selected data to DATA OUT.
    Loop NEVER.
    The purpose of the loop is just to have a shift reg. It doesn't really loop - it executes once per call.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • [SOLVED] systemd --user: "Failed to open private bus connection:"

    EDIT: The solution was to set DBUS_SESSION_BUS_ADDRESS, as suggested by gtmanfred in irc.  By putting the following before executing systemd --user, the error vanished:
    export DBUS_SESSION_BUS_ADDRESS=/run/user/$(id -u)/dbus/user_bus_socket
    ===================
    Original problem:
    Everything on my box appears to be working ok, but I'm getting this error consistently in tty1 and at the top of journalctl (as user) whenever I start systemd --user:
    systemd[3975]: Failed to open private bus connection: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
    I roughly have my system setup per this wiki section https://wiki.archlinux.org/index.php/Sy … ur_Session.  I start systemd --user via a small script in my .bash_profile. Here are my relevant dbus{.service,socket} files, from the package user-session-units mentioned in the wiki:  (Edit: xorg is started through xorg-launch-helper, also from that wiki page)  Edit2: I'm not using autologin.  I noticed that under the autologin section of that page, DBUS_SESSION_BUS_ADDRESS is set to some path.  In my setup that isn't set anywhere, so I may try to copy that later but I don't have time to play with it right now.  Will post back later.
    =====/usr/lib/systemd/user/dbus.service=====
    [Unit]
    Description=D-Bus System Message Bus
    Requires=dbus.socket
    [Service]
    ExecStart=/usr/bin/dbus-daemon --session --address=systemd: --nofork --systemd-activation
    ExecReload=/usr/bin/dbus-send --print-reply --session --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig
    =====/usr/lib/systemd/user/dbus.socket=====
    [Unit]
    Description=D-Bus System Message Bus Socket
    [Socket]
    ListenStream=%t/dbus/user_bus_socket
    And the output of sudo systemctl status dbus:
    dbus.service - D-Bus System Message Bus
    Loaded: loaded (/usr/lib/systemd/system/dbus.service; static)
    Active: active (running) since Tue 2013-02-05 14:50:30 EST; 22min ago
    Main PID: 369 (dbus-daemon)
    CGroup: name=systemd:/system/dbus.service
    └─369 /usr/bin/dbus-daemon --system --address=systemd: --no...
    Feb 05 14:50:30 sellers-laptop systemd[1]: Starting D-Bus System Message Bus...
    Feb 05 14:50:30 sellers-laptop systemd[1]: Started D-Bus System Message Bus.
    Feb 05 14:51:18 sellers-laptop dbus-daemon[369]: dbus[369]: [system] Activating via systemd: service name='org.freedesktop.Avahi' unit='dbus-org.freedesktop.Avahi.service'
    Feb 05 14:51:18 sellers-laptop dbus[369]: [system] Activating via systemd: service name='org.freedesktop.Avahi' unit='dbus-org.freedesktop.Avahi.service'
    Feb 05 14:51:18 sellers-laptop dbus[369]: [system] Activation via systemd failed for unit 'dbus-org.freedesktop.Avahi.service': Unit dbus-org.freedesktop.Avahi.service failed to load: No such file or directory. See system logs and 'systemctl status dbus-org.freedesktop.Avahi.service' for details.
    Feb 05 14:51:18 sellers-laptop dbus-daemon[369]: dbus[369]: [system] Activation via systemd failed for unit 'dbus-org.freedesktop.Avahi.service': Unit dbus-org.freedesktop.Avahi.service failed to load: No such file or directory. See system logs and 'systemctl status dbus-org.freedesktop.Avahi.service' for details.
    I'm not sure what the error even means or how to go about debugging it.  Any suggestions would be appreciated.
    Last edited by Feynman (2013-02-05 22:07:23)

    NVM...didn't notice it was already solved.
    Last edited by the sad clown (2013-02-05 22:33:10)

  • [SOLVED] What is the best way to load iptables/nftables on boot?

    Hi -
    New arch user migrating from Ubuntu/debian.  I'm used to loading netfilter iptable rules using an /etc/network/interfaces file.  What is the best way to do this using netctl/systemd?
    An RTFM of the wiki and a Google search didn't provide an answer, but maybe I'm just looking in the wrong places.
    Last edited by pgoetz (2014-06-21 08:32:01)

    Ah, OK -- got it.  I can just blindly enable the iptables.service, and systemd will make sure the interfaces are up before running the service.  How cool.  I'm still getting used to the luxury of not having to worry about stuff like this myself.  The only minor issue is it looks like I'll have to get the systemd nftables service out of AUR.
    Last edited by pgoetz (2014-02-24 19:58:53)

  • [Solved] Systemd user service and timer dbus error

    I have installed arch recently and added a few of my own services, for example the acpi_call commands and such. Now I want to create a systemd service that runs every 5 minutes and execute a script.
    I searched a lot and I found that I must use timers. I got the thing with the timers working, but because my script has to do with a specific user, I want it to run only every 5 minutes when i am logged in as that user.
    I tried to put the files in /etc/systemd/users, .config/local/users and all the possibilities but everytime i want to enable it, it says dbus connection refused.
    Can somebody please provide me a way to execute a systemd service every 5 minutes while I am logged in as a specific user?
    I did follow the wiki and created a dbus service and all. Everything works on that side but i can't enable my user service.
    thanks!
    Last edited by nopemopes (2015-03-25 11:10:06)

    jasonwryan wrote:
    What errors are you getting? https://bbs.archlinux.org/viewtopic.php?id=57855
    Not a Sysadmin issue, moving to NC...
    sorry, didn't mean to be incomplete.
    The error says "Failed to get D-Bus connection: Connection refused".
    I did what the wiki said: Create the dbus files, enable them and such.
    No i put my service files + timer in the places mentioned by the wiki but everytime i try to enable them, that error shows up.
    systemctl status dbus gives me all good
    dbus.service - D-Bus System Message Bus
    Loaded: loaded (/usr/lib/systemd/system/dbus.service; static; vendor preset: disabled)
    Active: active (running) since ma 2015-03-23 19:39:24 CET; 1h 18min ago
    Docs: man:dbus-daemon(1)
    Main PID: 246 (dbus-daemon)
    CGroup: /system.slice/dbus.service
    └─246 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
    mrt 23 19:39:34 Jordy-Laptop dbus[246]: [system] Activating via systemd: service name='org.freedesktop.ModemManager1' unit='...ervice'
    mrt 23 19:39:34 Jordy-Laptop dbus[246]: [system] Activation via systemd failed for unit 'dbus-org.freedesktop.ModemManager1....ectory.
    mrt 23 19:39:34 Jordy-Laptop dbus[246]: [system] Activating via systemd: service name='org.freedesktop.ModemManager1' unit='...ervice'
    mrt 23 19:39:34 Jordy-Laptop dbus[246]: [system] Activation via systemd failed for unit 'dbus-org.freedesktop.ModemManager1....ectory.
    mrt 23 19:39:39 Jordy-Laptop dbus[246]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='...ervice'
    mrt 23 19:39:39 Jordy-Laptop dbus[246]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
    mrt 23 19:47:01 Jordy-Laptop dbus[246]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='...ervice'
    mrt 23 19:47:01 Jordy-Laptop dbus[246]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
    mrt 23 20:51:38 Jordy-Laptop dbus[246]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='...ervice'
    mrt 23 20:51:38 Jordy-Laptop dbus[246]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
    that's the log for dbus and these are my files:
    drive_sync.service
    [Unit]
    Description=Drive sync
    [Service]
    Type=simple
    ExecStart=drive_script.sh
    drive_sync.timer
    [Unit]
    Description=Drive sync
    [Service]
    Type=simple
    ExecStart=drive_script.sh
    these files are located in ~/.config/systemd/user
    Last edited by nopemopes (2015-03-23 20:00:55)

  • [Solved] systemd/user : how to exit window manager & stop X?

    Solution: Jump to https://bbs.archlinux.org/viewtopic.php … 6#p1262166
    I have set up my system to user systemd units to start my environment (roughly following the wiki).
    My problem is that I cannot exit my window manager (using “io (exitWith ExitSuccess)” in Xmonad): the service file starting the WM (xmonad) stops/exits with success, but the xorg.service keeps
    running. I need to switch to TTY2, systemctl --user stop xorg.service by hand, then switch to TTY1, execute Ctrl-C, and then I finally get my login
    prompt back.
    This is a bit annoying, and I don't know how to fix it.
    Here are the relevant (I think) unit files:
    # xmonad.target
    [Unit]
    Description=XMonad
    Wants=xorg.target
    Wants=xinit.target
    Requires=dbus.socket
    AllowIsolate=true
    [Install]
    Alias=default.target
    # xmonad.service
    [Unit]
    Description=Starts Xmonad
    Before=xinitrc.target
    After=xorg.target
    Requires=xorg.target
    [Service]
    ExecStart=/usr/bin/xmonad
    Environment=DISPLAY=:0
    Restart=no
    [Install]
    WantedBy=xmonad.target
    RequiredBy=xorg.service
    As you can see, I have added the RequiredBy=xorg.service line at the bottom, hoping that if xmonad.service exits, so should xorg.service - but to
    no avail.
    What do I have to do in order to completely stop X and get my login prompt on TTY1 back?
    EDIT: I am of course using the user-session-units.
    Last edited by Stalafin (2013-04-22 13:54:45)

    I know it's an old thread (not really old) but I have the same problem. The question is your solution doesnt work with me. It just give me an error like this:
    Failed to issue method call: The name org.freedesktop.login1 was not provided by any .service files
    Failed to issue method call: Process /bin/false exited with status 1

  • Best way to Pass a Date with Time to a Page

    Has anyone come up with a simple and reliable way to pass a Date with Time "06/13/1992 10:50 PM" to a page.

    Hi Scott:
    On Page 1:
    Summary Report
    LINK  Window   Item Count      Start Date                   End Date
      X       1            7         8/2/2007 03:15:20   8/2/2007 03:18:22
      X       2          12         8/2/2007 04:01:01   8/2/2007 04:07:42When the LINK is clicked
    On Page 2:
    [:P2_S_DATE] 8/2/2007 03:15:20 [:P2_E_DATE] 8/2/2007 03:18:23 [:P2_GO]
    Detail Report
    Window   Item Number      Item Date
        1                1                8/2/2007 03:15:24
        1                2                8/2/2007 03:17:04
       ...              ...                        ...I then need to allow the users to adjust the dates and click the P2_GO and have it return the new result set.

  • Best way to pass back data from hierarchical table view?

    Hi,
    I have a view hierarchy using a navigation controller that's working pretty well. One of the bottom level views is a table view where the user selects an item from the list. This bottom view checks the list item, saves the selected item in a property, and then pops the view off the stack.
    What's the best way to alert the parent view that the child view has been popped off so it can retrieve the value in the property? The calling push returns immediately, so it doesn't appear to be a modal call. I want to be able to use the same controller from other parent forms, so I need to be able to do this without referencing the parent in the child form ideally.
    Thanks
    Ray

    Hi, well let me try to explain it a bit more
    - Add a "delegate" property to your child-viewcontroller-class
    - Define a protocoll within each chil-viewController-class
    In this example let us name it "didSelectValue:(NSString *)value"
    - In the parent-viewcontroller before pushing a child-viewcontroller set it's delegate property to "self" (parent-viewcontroller)
    - In the parent-viewcontroller implement to protocoll-method "didSelectValue:(NSTring *)value"
    - In the child view-controller in (assuming it is a tableViewcontroller) add some code in didSelectRowAtIndexPath that checks if the delegate is set and check if it responds to selector "didSelectValue:(NSString *)value". If so, call it with the selected value.

  • Best way to pass large amounts of data to subroutines?

    I'm writing a program with a large amount of data, around 900 variables.  What is the best way for me to pass parts of this data to different subroutines?  I have a main loop on a PXI RT Controller that is controlling hydraulic cylinders and the loop needs to be 1ms or better.  How on earth should I pass 900 variables through a loop and keep it at 1ms?  One large cluster??  Several smaller clusters??  Local Variables?  Global Variables??  Help me please!!!

    My suggestion, similar to Altenbach and Matt above, is to use a Functional Global Variable (FGV) and use a 1D array of 900 values to store the data in the FGV. You can retrieve individual data items from the FGV by passing in the index of the desired variable and the FGV returns the value from the array. Instead of passing in an index you could also use a TypeDef'd Enum with all of your variables as element of the Enum, which will allow you to place the Enum constant on the diagram and make selecting variables, as well as reading the diagram, simpler.
    My group is developing a LabVIEW component/example code with this functionality that we plan to publish on DevZone in a month or two.
    The attached RTF file shows the core piece of this implementation. This VI off course is non-reentrant. The Init case could be changed to allocate the internal 1D array as part of this VI rather than passing it from another VI.
    Message Edited by Christian L on 01-31-2007 12:00 PM
    Christian Loew, CLA
    Principal Systems Engineer, National Instruments
    Please tip your answer providers with kudos.
    Any attached Code is provided As Is. It has not been tested or validated as a product, for use in a deployed application or system,
    or for use in hazardous environments. You assume all risks for use of the Code and use of the Code is subject
    to the Sample Code License Terms which can be found at: http://ni.com/samplecodelicense
    Attachments:
    CVT_Double_MemBlock.rtf ‏309 KB

  • What is the best way to pass a constant to a cin expecting a pointer to a value?

    I have a cin which has a leg that is expecting a pointer to a value. On the diagram, what is the best way to connect a constant widget to this leg of the cin? Connecting it directly crashes labview as it treats the constant as a pointer to memory.
    Thanks

    I am not sure that I understand your issue. CIN variables can be Input-Output or Output only. Either way, they are being passed in as a pointer to a value. You can see this very easily by placing down a CIN and wiring a constant integer to it. Next, right-click on the CIN and create the C file. You will see that the parameter list has an int* in it.
    If you are still having problems, do you have to create a CIN or can you create a DLL instead? The DLL will give you a few more ways to pass the data than a CIN does with no real performance decrease.
    Also, have you read the "Using External Code in LabVIEW" manual? This hsould answer some questions as well.
    Randy Hoskin
    Applications Engineer
    National Instruments
    http://www.ni.com/ask

Maybe you are looking for