DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

binary file with linefeed

Solved!
Go to solution

Hello

Today, I need to import data from a mixed binary/text file. Structure is

 

Ch1 Byte1      Ch1 Byte2     Ch2 Byte1    Ch2 Byte2     CrLf

Ch1 Byte1      Ch1 Byte2     Ch2 Byte1    Ch2 Byte2     CrLf

Ch1 Byte1      Ch1 Byte2     Ch2 Byte1    Ch2 Byte2     CrLf

 

 

 

My first attempt was a modified DataPluginExample3.VBS

 

Sub ReadStore(File)

 

Dim Block : SetBlock = File.GetBinaryBlock()

Dim Channel1 : Set Channel1 = Block.Channels.Add("Low-Timer",eU16)

Dim Channel2 : Set Channel2 = Block.Channels.Add("High-Timer", eU16)

Dim Channel3 : Set Channel3 = Block.Channels.Add("CrLf", eU16)

Dim ChannelGroup : Set ChannelGroup = Root.Channelgroups.Add("ESR_Timing")

ChannelGroup.Channels.AddDirectAccessChannel(Channel1)

ChannelGroup.Channels.AddDirectAccessChannel(Channel2)

ChannelGroup.Channels.AddDirectAccessChannel(Channel3)
'Kanal 3 ist nur $OD$OA CrLf)

End Sub

 

Unfortunately, every odd sample, the data are corrupted and then become misaligned. And the beginning of datalogging may not start exactly at a new line.

So I'd like to use the CrLF to re-synch.

How can I mix the ASCII-readline approach with the binary data?

 

The following does not work: I try to tell the Formatter to use vbNewLine (=CrLf = $0d$0a) to separate lines and use direct access channels with U16 data type. But when using linefeed, apparently the import filter also expects delimiters instead of raw binary values.

 

Sub ReadStore(File)

File.Formatter.LineFeeds = vbNewLine

File.SkipLine()'Sicherstellen, dass unvollständige erste Zeile ignoriert wird

Dim Block : SetBlock = File.GetStringBlock()

Dim Channel1 : Set Channel1 = Block.Channels.Add("Low-Timer",eU16)

Dim Channel2 : Set Channel2 = Block.Channels.Add("High-Timer", eU16)

'Dim Channel3 : Set Channel3 = Block.Channels.Add("CrLf", eU16)

Dim ChannelGroup : Set ChannelGroup = Root.Channelgroups.Add("ESR_Timing")

ChannelGroup.Channels.AddDirectAccessChannel(Channel1)

ChannelGroup.Channels.AddDirectAccessChannel(Channel2)

End Sub

 

 

Thank you for your input.

Michael

0 Kudos
Message 1 of 4
(5,970 Views)

Hi Michael,

 

It looks like you're already on the right track, but you need to ignore all the ASCII formatting options and proceed purely with binary formatting.  Can you send me the file in question?  It looks like your approach should have more success than you're reporting.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 4
(5,957 Views)

Hi Brad

Please find attached my datalog as recorded by Hterm. As it is a terminal recorded session, starting point is arbitrary....

 

Thanx in advance for your assistance.

Michael

 

 

0 Kudos
Message 3 of 4
(5,944 Views)
Solution
Accepted by topic author nimic

Hi Michael,

 

I think this DataPlugin does the trick.  I had to ignore any partial first line values in order to preserve the line correspondence of the low and high timer values.  Also note that by default the U16s are read with LittleEndian byte order-- you can change that with File.Formatter.ByteOrder=eBigEndian.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Download All
0 Kudos
Message 4 of 4
(5,928 Views)