LabVIEW: Extract data after a certain line - labview

Any advice or help would be much appreciated.
Question: How to extract data after a certain line from a comma deliminated strings which are read from a serial port ?
More Info: A have a card that is gathering data values and is read into the computer via a serial port. Example string of data acquired as below:
;Data = 1 bps Tool = Sensor
;Label, Time, Voltage, Pressure, Temperature, Current
A, 01:33, 5.1, 18.1, 31.2, -,
B, 01:34, 5.5, 19.2, 30.5, -,
;Data = 1 bps Tool = Sensor
;Label, Time, Voltage, Pressure, Temperature, Current
A, 01:35, 5.3, 18.3, 30.1, -,
B, 01:36, 5.1, 19.0, 30.5, -,
;Data = 1 bps Tool = Sensor
;Label, Time, Voltage, Pressure, Temperature, Current
A, 01:37, 5.1, 18.1, 30.8, -,
B, 01:38, 5.3, 19.2, 30.1, -,
These data value will be kept updating line by line. I would like to start extracting the data only on the 3rd block of incoming data. I would not want the first 2 blocks of incoming data.
Further Info: Currently, my idea of doing that is to scan the ";Data" and put it into a counter. If there are 2 ";Data" scan, then from the counter it woud output a True value to a case structure to start extracting the data. Please see my attached photo.
However, I am not able to create such a counter using an array as I cannot use a while loop and shift register. Do you have any idea how to start extracting data from 3rd block onwards ? Thank you very much.

Hopefully I understand the question properly. Here is my solution:
Code can be found here: http://raptorview.net/StackOverflow/SO19920265.vi

Related

Read text file using fortran, where the starting 18 lines are strings and the rest of the lines are real numbers in 1000*8 array?

I have a text file where the first few lines are text and the rest of the lines contain data in the form of real numbers. I just require the real numbers array to be stored in a new file. For this, I read the total lines of the file for which output is correct and then trying to read the real numbers from the particular line numbers. I am unable to understand as to how to read this data.
Below is a part of file. Also I have many files like these to read.
AptitudeQT paperI: 12233105
Latitude : 30.00 S
Longitude: 46.45 E
Attemptone Time: 2017-03-30-09-03
End Time: 2017-03-30-14-55
Height(agl): m
Pressure: hPa
Temperature: deg C
Humidity: %RH
Uvelocity: cm/s
Vvelocity: cm/s
WindSpeed: cm/s
WindDirection: deg
---------------------------------------
10 1008.383 27.655 62.200 -718.801 -45.665 720.250 266.500
20 1007.175 27.407 62.950 -792.284 -18.481 792.500 268.800
There are many examples how to skip/read lines like this
But to sum it up, option A is to skip header and read only data:
! Skip first 17 lines
do i = 1, 17
read (unit,*,IOSTAT=stat) ! Dummy read
if ( stat /= 0 ) stop "error"
end do
! Read data
do i = 1, 1000
read (unit,*,IOSTAT=stat) data(:,i)
if ( stat /= 0 ) stop "error"
end do
If you have many files like this, I suggest wrapping this in a subroutine/function.
Option B is to use unix tail utility to discard header (more info here):
tail -n +18 file.txt

Same Pandas Data Frames are different in size

I have two data frames A & B saved as pickles, on both Computer 1 (running Ubuntu) and 2 (running MacOSX)
I merge A & B into Data Frame C and save it as X.h5 (HDF format, on both Computers)
However, X.h5 in Computer 1 has smaller size (188MB) than X.h5 in Computer 2 (196MB). I copied X.h5 from Computer 1 to Computer 2, they are still different in size (and also in binary files). But when I use pandas to read both of them, X_h5_computer1.equals(X_h5_computer2) return True
Why it happened? The size difference is significant.
Thank you

How to transmit data using GFSK modulation?

I am new to this domain.
I want to transmit data using GFSK modulation using GNU Radio which response to the following specifications :
Deviation : +/-2,4 kHz +0,2%
Modulation index : 2
Filter index : 0.5 BT
Bitrate : 2400 bit/s
I want to transmit this data (data is in HEXA):
Preamble : 55 55
Synchro : F6 72
L-field ( data + CRC) : 20
Please start with the gr-digital (part of GNU Radio dist) GFSK Mod block. Take a peek at the source python, and then you'll want to look at the gr-analog frequency_modulation.h source for details about FM, specifically frequency deviation. For some reason, the doxygen output does not generate the embedded formula, which is why looking at the header file is suggested.
Then I suggest you do some simple experiments in GNU Radio Companion to better understand the GFSK Mod block.
Hope this helps.
I have based on this example of FSK transmitter, https://nccgroup.github.io/RFTM/fsk_transmitter.html
so you need juste to put the value of BT equal to 0.5 to make a GFSK transmitter. And everthing works correctely.

[Q]uestion about reading and saving a large txt-file via {RSQLite} line by line into a DB

Since my hardware is very limited (a dual core with 32bit Win7 and 4GB of ram - I need to make the best of it.....) I try to save a large text-file (about 1.2GB) into a DB, which I can then trigger by SQL-like queries to do some analytics on particular subgroups.
To be honest I'm not familiar with this area and since I could not find help regarding my issues via "googling", I just quickly show what I came up with and how I thought things would look like:
First I check how many columns my txt-file has:
k <- length(scan("data.txt", nlines=1, sep="\t", what="character"))
Then I open a connection to the text file so that it does not need to be opened
again for every single line:
filecon<-file("data.txt", open="r")
Then I initialize a connection (dbcon) to an SQLite database
dbcon<- dbConnect(dbDriver("SQLite"), dbname="mydb.dbms")
I find out where the position of the first line is
pos<-seek(filecon, rw="r")
Since the first line contains the column-names I save them for later use
col_names <- unlist(strsplit(readLines(filecon, n=1), "\t"))
Next, I test to read the first 10 lines, line by line,
and save them into a DB, which themself (should) contain k - columns with columns-names = col_names.
for(i in 1:10) {
# prints the iteration number in hundreds
if(i %% 100 == 0) {
print(i)
}
# read one line into a variable tt
tt<-readLines(filecon, n=1)
# parse tt into a variable tt2, since tt is a string
tt2<-unlist(strsplit(tt, "\t"))
# Every line, read and parsed from the text file, is immediately saved
# in the SQLite database table "results" using the command dbWriteTable()
dbWriteTable(conn=dbcon, name="results", value=as.data.frame(t(tt2[1:k]),stringsAsFactors=T), col.names=col_names, append=T)
pos<-c(pos, seek(filecon, rw="r"))
}
If I run this I get the following error
Warning messages:
1: In value[[3L]](cond) :
RS-DBI driver: (error in statement: table results has 738 columns but 13 values were supplied)
Why should I supply 738 columns? If I change k (which is 12) to 738, the code works but then I need to trigger the columns by V1, V2, V3,.... and not by the column-names I intended to supply
res <- dbGetQuery(dbcon, "select V1, V2, V3, V4, V5, V6 from results")
Any help or even a small hint is very much appreciated!

Statically Defined IDT

This question already has answers here:
Solution needed for building a static IDT and GDT at assemble/compile/link time
(1 answer)
How to do computations with addresses at compile/linking time?
(2 answers)
Closed 5 days ago.
I'm working on a project that has tight boot time requirements. The targeted architecture is an IA-32 based processor running in 32 bit protected mode. One of the areas identified that can be improved is that the current system dynamically initializes the processor's IDT (interrupt descriptor table). Since we don't have any plug-and-play devices and the system is relatively static, I want to be able to use a statically built IDT.
However, this proving to be troublesome for the IA-32 arch since the 8 byte interrupt gate descriptors splits the ISR address. The low 16 bits of the ISR appear in the first 2 bytes of the descriptor, some other bits fill in the next 4 bytes, and then finally the last 16 bits of the ISR appear in the last 2 bytes.
I wanted to use a const array to define the IDT and then simply point the IDT register at it like so:
typedef struct s_myIdt {
unsigned short isrLobits;
unsigned short segSelector;
unsigned short otherBits;
unsigned short isrHibits;
} myIdtStruct;
myIdtStruct myIdt[256] = {
{ (unsigned short)myIsr0, 1, 2, (unsigned short)(myIsr0 >> 16)},
{ (unsigned short)myIsr1, 1, 2, (unsigned short)(myIsr1 >> 16)},
etc.
Obviously this won't work as it is illegal to do this in C because myIsr is not constant. Its value is resolved by the linker (which can do only a limited amount of math) and not by the compiler.
Any recommendations or other ideas on how to do this?
You ran into a well known x86 wart. I don't believe the linker can stuff the address of your isr routines in the swizzled form expected by the IDT entry.
If you are feeling ambitious, you could create an IDT builder script that does something like this (Linux based) approach. I haven't tested this scheme and it probably qualifies as a nasty hack anyway, so tread carefully.
Step 1: Write a script to run 'nm' and capture the stdout.
Step 2: In your script, parse the nm output to get the memory address of all your interrupt service routines.
Step 3: Output a binary file, 'idt.bin' that has the IDT bytes all setup and ready for the LIDT instruction. Your script obviously outputs the isr addresses in the correct swizzled form.
Step 4: Convert his raw binary into an elf section with objcopy:
objcopy -I binary -O elf32-i386 idt.bin idt.elf
Step 5: Now idt.elf file has your IDT binary with the symbol something like this:
> nm idt.elf
000000000000000a D _binary_idt_bin_end
000000000000000a A _binary_idt_bin_size
0000000000000000 D _binary_idt_bin_start
Step 6: relink your binary including idt.elf. In your assembly stubs and linker scripts, you can refer to symbol _binary_idt_bin_start as the base of the IDT. For example, your linker script can place the symbol _binary_idt_bin_start at any address you like.
Be careful that relinking with the IDT section doesn't move anyting else in your binary, e.g. your isr routines. Manage this in your linker script (.ld file) by puting the IDT into it's own dedicated section.
---EDIT---
From comments, there seems to be confusion about the problem. The 32-bit x86 IDT expects the address of the interrupt service routine to be split into two different 16-bit words, like so:
31 16 15 0
+---------------+---------------+
| Address 31-16 | |
+---------------+---------------+
| | Address 15-0 |
+---------------+---------------+
A linker is thus unable to plug-in the ISR address as a normal relocation. So, at boot time, software must construct this split format, which slows boot time.