Jump to content

eberaud

Members
  • Posts

    297
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by eberaud

  1. Hi, I am writing a LabVIEW API based on a 3rd party DLL. The DLL function I am working on right now returns a string and 2 U32. The string is only an output, but the 2 U32 are used as both inputs and outputs. So long story short the 3 parameters are defined as pointers. The 2 U32 work as specified in the documentation, one of them (psize) returning the number of characters that the string is supposed to return. However I can't get the string properly. The documentation tells me that it is a C String and I configured the parameter as such, but when I run the function I get only the first character of what I'm supposed to get. The next test I made (see below) returns all the other characters except the first one and helped me understand why this first test returned only the first character: the string is Unicode! This means that each character (though able to be represented in ASCII) takes 2 bytes, one of them being the null character. And since a C string ends when the null character is encountered, this explain why LabVIEW only gives me the ASCII value of the first character. In the second test I'm talking about, I modified the parameter to be a Pascal String Pointer instead of C String Pointer. I got all the characters except the first one, which makes sense I guess since the first character is the length in a Pascal string. Basically so far I haven't managed to find a way to read the whole string in one call. I would love to find a solution where I just ask for an array of bytes and just perform my own parsing, but the DLL returns an Invalid Parameter error when I try it. Have you run into something similar? Do you have any tips? Help would be much appreciated!! (on top of this issue, LabVIEW crashed 50% of the time )
  2. Thank you all for your answers. The device I'm talking to is an Arduino with strict parsing, and the firmware code takes only floating numbers. I can't always multiply/divide by 100 since we want more precision when the number is small (0.123) and less precision when the number is big (12.3). Like you said Phillip, the decimal point is also a character... I'll probably go with Sparc's method : format differently, based on the amplitude of the value, even though I wanted to avoid extra checks... Too bad there isn't a 3rd choice in the formatting option: 1) Number of significant digits (%_3f) 2) Number of digits of precision (%.3f) 3) Maximum number of digits (maybe %*3f or whatever else)
  3. It's not just a cosmetic issue, the string is sent to a serial device through VISA at quite a high rate (up to 10ms) so I want to find the most optimized solution...
  4. As far as I now there is 2 way to define how to format a numeric into a string using the floating point representation (%f): - Setting the number of significant digits (%_2f) - Setting the number of digits or precision (%.2f) However I often find myself in the need of a way to define the width of the string. For example I always want 3 digits maximum. Using significant digits won't work if the number is 0.0012 since this only has 2 significant digits, so the string will be 0.0012 even though I would like to see 0.00 (so 0 if we hide trailing zeros). On the other hand, using digits of precision won't work if I have a number like 123.45 since it has 2 digits of precision, so the string will be 123.45 even though I would like to see 123. Now the obvious brutal way would be to use a string subset and only keep the first 3 digits (I guarantee that my number is never bigger than 999). But I really hope there is a more elegant way. I can't imagine that nobody has run into this requirement before. How did you tackle it?
  5. 2 different and equally nice solutions. Thanks for posting them!
  6. I think you should only accept the negative sign (-) to be at the beginning of the string. Right now it will accept "5-5" but that's not really a number...
  7. Perfect analysis. I fixed the issue by putting a case structure in the combobox value change event. I only perform the code that updates the value of the tree if the combobox has the keyfocus. This disables the selection through the dropdown of the combobox, but in my actual application I hide the dropdown button anyway. Thanks ned
  8. I have been trying to understand what's going on with my tree control and I'd like to share this with the community to see if somebody has seen this behavior before. Maybe there is something obvious that I am not seeing... I attached the VI (LV2011) with instructions inside (will take you 20s to perform the experiment, I dismantled the VI to its bare minimum). Please don't comment on the overall architecture (state machine...) since I modified the VI just for the sake of posting it here and removed all advanced features. Long story short, after programmatically modifying the value of the tree, I modify its value a second time by clicking directly on one of the tree items. I then expect the NewVal value given through the left node of the value change event case to match the value of the tree terminal. Depending on the code that first modified the value programmatically, sometimes this expectation is met and sometimes it isn't. Run the code, it's easier to understand that way... Thanks for your feedback! Tree value issue.vi
  9. Weird. There is a similar check inside ...\vi.lib\gmath\parser.llb\Number Split.VI but this one seems right (44:comma, 46:dot)
  10. Yes actually I have been using this exact technique for a while. Thank you for the clarification
  11. Old thread, but I know threads have a long life on LAVA I just wanted to get clarification about one aspect of this great paper. The factory pattern is used to reduce the linking, and I understand how it does that. But in this example, loading just the dinner simulator class will load all the applicances children and all the cookbehaviors children, so this example doesn't take advantage of the ability of the factory pattern to avoid loading children classes, as explain here for example. Am I correct? The example given in the video uses the Get LV Class Default Value.vi to achieve that.
  12. Wow I didn't even know you could extend it! Thanks for the help Thomas
  13. I've always found that the LabVIEW help didn't explain well enough how the Match Pattern and the Match Regular Expression work. Do you know a good source for learning more about how to use them properly? Thanks
  14. Well with an explicit node (is that an official wording?) you don't get a reference, so you couldn't close it anyway even if you wanted to
  15. The history data is probably not lost. It's just that LabVIEW forgets to retrieve it. If you force a change of scale (for example modify the autoscale property of the X scale), then the whole history data should be retrieved. But long story short, a consensus is that charts are nice quick way to view some data while you're analyzing a certain part of your code during development, but they are not suited for a permanent solution in an application. In the latter case, you want to switch to graphs (either waveform or XY based on your needs).
  16. Things are much clearer now. Thanks! I guess my main reason for using a timed loop is that I "feel" the duration of each iteration (I mean the time gap between the start of iteration n and the start of iteration n+1) is easily controlled and measured. If I use a while loop and I want each iteration to last 10ms, all I can do is throw a "wait until next multiple" that executed in parallel with the rest of the code inside the loop, but I have no guarantee that the duration I'm talking about will be 10ms, and it's hard to measure as well...
  17. Wow this changes things a lot. We have timed loops all over the place (CAN driver, datalogging engine, graphing engines, automation engine, ...). Are you suggesting to replace them with regular WHILE loops? Edit: Can you direct me to a resource explaining the cost of timed loops? I couldn't find anything but advantages online...
  18. I just created a very lean exe that will simply pop-up a message when the time stamp will be bad. I'll post here to say whether I could reproduce the issue or not. I've thought about the workaround you suggest, but since the primitive you talking about doesn't have an error input, it would execute in parallel with other constructs inside the loop, which doesn't provide the same accuracy. Unless I use a sequence of course, but I don't want to add more code than is necessary in this loop since I need it to run fast. Thanks for your reply
  19. BUMP. I think this is an issue worth to worry about. Do you think I should request NI to create a CAR?
  20. The simplest way I can think of is to have the "brat" code generate the signalling event and also set a Boolean to True. The event case "Value change" can read this Boolean and always set it to False afterwards. If it's true, the event was fired by the "brat", if it's false, it was fired by the UI.
  21. Unfortunately I didn't manage to dig deep into your code since a lot of it is beyond the scope of TDMS. However here is how my architecture works, in case it can inspire you: Writer side: Create file withDisable Buffering = False Asynchronous = False (I use Synchronous R/W) Set Channel Information (couldn't find this one on your diagram but again I didn't look everywhere)Channel names : the number of rows my 2D Array has in a write operation Samples per channel = how many samples for each channel at each write operation (number of columns my 2D Array has) Write using a 2D array that I don't need to transpose since it's built to have channels = rows and samples = columns (Advanced Synchronous Write) Reader side: Open file withDisable Buffering = False Asynchronous = False (I use Synchronous R/W) Operation = Open (read-only) --> I think this is where you'll get an error if you don't open it in read-only Read data usingSet Next Read Position Advanced Synchronous Read Edit: and of course both the reader and writer can perform their tasks on the same file simulateously
  22. Well I don't have an explanation unfortunately but I can reproduce it at least!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.