Skip to content

IR-Packet-Buffer only returns 7 Bytes #21

@R-Klimkeit

Description

@R-Klimkeit

Hello,

I'm stuck with this little Visual-Studio Code-Snippet (used sdk-master\libs\include\Win64\libflirc.dll)

Imports System.Runtime.InteropServices

Module Module1
    Private Const MAX_EDGES As Integer = 256
    Private Const MAX_DESC As Integer = 100


    Sub Main()
        Dim RetVal As Integer = fl_open_device_alt(&H20A0, "flirc.tv")
        If (RetVal < 0) Then
            MsgBox("Error opening FLIRC-Device")
            End
        End If

        While (True)
            Dim packet As ir_packet = Nothing
            RetVal = fl_ir_packet_poll(packet)
            If (RetVal = 1) Then
                Console.WriteLine("Buf-Len:" & packet.len & " | Elapsed:" & packet.elapsed & " | Raw-Data:" & String.Join(" ", packet.buf).Replace(" 0", ""))
            End If
        End While
    End Sub

    <System.Runtime.InteropServices.DllImport("libflirc.dll")> Public Function fl_open_device_alt(ByVal VID As UInt16, <MarshalAs(UnmanagedType.LPWStr)> ByRef Enumerator As String) As Integer
    End Function
    <System.Runtime.InteropServices.DllImport("libflirc.dll")> Public Function fl_ir_packet_poll(ByRef packet As ir_packet) As Integer
    End Function

    <StructLayout(LayoutKind.Sequential)> Public Structure ir_prot
        Public protocol As UInt16                                                             'used to override protocol to sub protocol, NEC->APPLE_NEC
        Public scancode As UInt32                                                             '32 Bit Scancode from remote
        Public fullcode As UInt64                                                             '32 bit entire code extracted from remote (don't use this)
        Public hash As UInt32                                                                 '32 Bit Unique Hash
        Public repeat As Byte                                                                 'repeat detected=1 / no repeat=0
        Public bits As UInt32                                                                 'amount of bits collected
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=MAX_DESC)> Public desc() As Char      'Used to describe our collected signal
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=MAX_EDGES)> Public buf() As UInt16    'cleaned signal after decode
        Public len As UInt16                                                                  'length of clean buf
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=MAX_EDGES)> Public pronto() As UInt16 'pronto hex code
        Public pronto_len As UInt16                                                           'pronto length
    End Structure

    <StructLayout(LayoutKind.Sequential)> Public Structure ir_packet
        <MarshalAs(UnmanagedType.ByValArray, SizeConst:=256)> Dim buf() As UInt16
        Public len As UInt16
        Public elapsed As UInt16
    End Structure
End Module

Works like a charm, but I just realized, that the IR-Packet will only show the last 7 Raw-Bytes
Image

Using "irtools.exe listen" from the FLIRC-Installer will show all IR-received bytes - Any idea what's wrong with my code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions