B4J Question Weird phenomenon with lists

Blueforcer

Well-Known Member
Licensed User
Longtime User
Ok, maybe im blind and someone can help me:)
I get data vie UDP, calculate a RGB565 picture (array as short) from it, and save every frame to a list.
While adding to the list i log the first short of the array wich contains data.
Then if there is no more data coming i want to compute the list. But after filling the list, the list contains every frame,but every single frame is a short array (265) with only zeros.

B4X:
Sub Process_Globals
    Dim UDPSocket As UDPSocket
    Dim t As Timer
    Dim record As Boolean =True
    Dim recordlist As List
    Dim universe1Send As Boolean
    Dim universe2Send As Boolean
    Dim bmp(256) As Short
End Sub

Sub start
    recordlist.Initialize
    If UDPSocket.IsInitialized Then UDPSocket.Close  
    UDPSocket.Initialize("UDP", ACN_Port, 5000)
    t.Initialize("timer",5000)
End Sub

Sub UDP_PacketArrived (Packet As UDPPacket)

    t.Enabled=False
    t.Enabled=True

    If Packet.Data(universebyte)=1 Then
        For i=0 To 127
            Dim j As Int = i * 3 + (CHANNEL_START)
            bmp(i)=get565(Packet.Data(j),Packet.Data(j+1),Packet.Data(j+2))
        Next
        universe1Send=True
    Else if Packet.Data(universebyte)=2 Then
        For a=128 To 255
            Dim j1 As Int =(a-128) * 3 + (CHANNEL_START)
            bmp(a)=get565(Packet.Data(j1),Packet.Data(j1+1),Packet.Data(j1+2))
        Next
        universe2Send = True
    End If
      
    If universe1Send And universe2Send Then
        If record Then
            addToList(bmp)
        End If
        universe2Send=False
        universe1Send=False
    End If
End Sub

Sub addToList(frame() As Short)
    Log(frame(0))
    recordlist.Add(frame)
End Sub

Sub Timer_Tick
dim frame() as short = recordlist.get(0)
log(frame(0))
End Sub
 

drgottjr

Expert
Licensed User
Longtime User
do you know for a fact that:
B4X:
            Dim j As Int = i * 3 + (CHANNEL_START)
            bmp(i)=get565(Packet.Data(j),Packet.Data(j+1),Packet.Data(j+2))
and its sibling are not giving you anything but 0's? did you log that phase? where is get565()? what's it outputting?
 
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
Of course ;) As i wrote: Its all working. I log it at line 47 and 53. I also debugged it. While filling i had a look at the whole array, and every data is available as it should. After my timer ticks every frame is zero.
 
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
So a log output from sending e131 data:
As you can see. on line 95 every frame is filled with data (last one is always zero if i stop the transmission). If i read it on line 112 all data its zero
1586246307677.png
 
Upvote 0

Blueforcer

Well-Known Member
Licensed User
Longtime User
Thats because one udp package only contains the half of the complete frame.
So i need two packages to fill the whole 256 datapoints. Thats why i only add it to the list if universe1Send and universe2Send is true.
 
Upvote 0
Top