Thank you for such a quick reply, that has worked a treat!
Is there any particularly reason why it would normally be called separately? It seems in the situation where you have a pc running python sending messages to a microcontroller you would always want the corresponding pb files generated at the same time, and conveniently with the platformio plugin it only calls this command on build if the proto file has changed since last generation.
Im sure others will use platformio and nanopb in the future so for reference, if you are wanting to generate both nanopb-c and python protocol buffer files with the nanopb plugin in platformio the .ini file should look like this:
[env:teensy41]
platform = teensy
board = teensy41
framework = arduino
lib_deps =
nanopb/Nanopb
custom_nanopb_protos =
+<../proto/packet_config.proto>
custom_nanopb_options =
--error-on-unmatched --protoc-opt="--python_out=<path_to_where_you_want_your_python_pb_files>"
build_flags = -D USB_RAWHID
The _.pb.c and _.pb.h files that nanopb generates get put in the .pio/build/teensy41/nanopb/generated-src folder, and can be included as you normally would in your project files.