I have the following decoded protobuf data:
```
Field 1: 103281
Field 2: 2022-02-13
Field 3:
Field 1: 581752
Field 2:
Field 1: 4
Field 2: 07:00
Field 2: 07:15
Field 2: 07:30
Field 2: 07:45
Field 2: 08:00
Field 2: 08:15
Field 2: 08:30
Field 2: 08:45
Field 4:
Field 1: 1
Field 2:
Field 1: ParsedResults(results=[ParsedResult(field=1,
wire_type='fixed32', data=Fixed32Value(int:1110966272, float:46.0)),
ParsedResult(field=2, wire_type='fixed32',
data=Fixed32Value(int:1008981770, float:0.009999999776482582)),
ParsedResult(field=3, wire_type='fixed32',
data=Fixed32Value(int:1058642330, float:0.6000000238418579)),
ParsedResult(field=5, wire_type='varint', data=1)])
Field 1: Fixed32Value(int:1110966272, float:46.0)
Field 2: Fixed32Value(int:1008981770,
float:0.009999999776482582)
Field 3: Fixed32Value(int:1058642330, float:0.6000000238418579)
Field 5: 1
```
I'm having trouble accessing the data within:
```
Field 1: Fixed32Value(int: 1110651699, float: 44.79999923706055)
Field 2: Fixed32Value(int: 1008981770, float: 0.009999999776482582)
Field 3: Fixed32Value(int: 1058642330, float: 0.6000000238418579)
Field 5: 1
```
My schema looks like this:
```
syntax = "proto3";
message PVStart {
int32 sid = 1;
string date = 2;
PVData pv_data = 3;
message PVData {
repeated int32 pvid = 1;
TimeData time_data = 2;
}
message TimeData {
repeated int32 timeID = 1;
repeated string time = 2;
placeholder p_one = 4;
message placeholder {
repeated int32 one = 1;
placeholdertwo p_two = 4;
message placeholdertwo {
VCPData vcp_data = 1;
message VCPData {
repeated float voltage = 1;
repeated float current = 2;
repeated float power = 3;
}
}
}
}
}
```
I'm using the following Python code to decode the message:
```
import my_schema_pb2
# Open the binary file
with open("my_data.bin", "rb") as f:
data = f.read()
message = my_schema_pb2.PVStart()
message.ParseFromString(data)
sid = message.sid
date = message.date
pvid = message.pv_data.pvid[0]
time = message.pv_data.time_data.time[0]
timeID = message.pv_data.time_data.timeID[0]
one = message.pv_data.time_data.p_one.one[0]
vcp_data = message.pv_data.time_data.p_one.p_two.vcp_data
voltage = vcp_data.voltage
current = vcp_data.current
power = vcp_data.power
print("SID:", sid)
print("DATE:", date)
print("PANELID:", pvid)
print("TimeID:", timeID)
print("Time:", time)
print("ID/Placeholder?:", one)
print("Voltage (V):", voltage)
print("Current (A):", current)
print("Power (W):", power)
```
When I run my Python code to access the protobuf data, I get the following
output in my console:
```
SID: 103281
DATE: 2022-02-13
PANELID: 581752
TimeID: 4
Time: 07:00
ID/Placeholder?: 1
Voltage (V): []
Current (A): []
Power (W): []
```
Despite attempting to modify my schema, I have no control over the encoded
data, and I'm still unable to retrieve values for Voltage, Current, and
Power. Can someone please help me understand what I might be doing wrong or
how to access these fields correctly?
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/protobuf/955b5630-4b8e-4479-ab83-c4afe73c34cdn%40googlegroups.com.