I am just trying to generate code for golang using protocol buffer. But unable to generate the service using protoc command.
syntax = "proto3";
package greet;
option go_package="./greet/greetpb";
service GreetService{}
Above is a dummy proto file that I am trying to convert into golang. But unable to generate the correct file as in my system it doesn't recognize service GreetService{} line as a service.
I am using the following version of protoc on windows system:
PS D:\Study\grpc\go-grpc-course> protoc --version
libprotoc 3.17.3
Using below command to generate the code:
protoc .\greet\greetpb\greet.proto --go_out=.
Below is the go code generated by above command:
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc v3.17.3
// source: greet/greetpb/greet.proto
package greetpb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
var File_greet_greetpb_greet_proto protoreflect.FileDescriptor
var file_greet_greetpb_greet_proto_rawDesc = []byte{
0x0a, 0x19, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2f, 0x67, 0x72, 0x65, 0x65, 0x74, 0x70, 0x62, 0x2f,
0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x67, 0x72, 0x65,
0x65, 0x74, 0x32, 0x0e, 0x0a, 0x0c, 0x47, 0x72, 0x65, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x42, 0x11, 0x5a, 0x0f, 0x2e, 0x2f, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2f, 0x67, 0x72,
0x65, 0x65, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var file_greet_greetpb_greet_proto_goTypes = []interface{}{}
var file_greet_greetpb_greet_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_greet_greetpb_greet_proto_init() }
func file_greet_greetpb_greet_proto_init() {
if File_greet_greetpb_greet_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_greet_greetpb_greet_proto_rawDesc,
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_greet_greetpb_greet_proto_goTypes,
DependencyIndexes: file_greet_greetpb_greet_proto_depIdxs,
}.Build()
File_greet_greetpb_greet_proto = out.File
file_greet_greetpb_greet_proto_rawDesc = nil
file_greet_greetpb_greet_proto_goTypes = nil
file_greet_greetpb_greet_proto_depIdxs = nil
}
There aren't any services created in the later go code. Am I doing something wrong or is this some proto issue. Any help is appreciated.
You seem to forgot to add the go-grpc_out argument when using protoc. This argument is for generating the gRPC code. Please try the following:
protoc greet.proto --go_out=. --go-grpc_out=.
This is also described in the gRPC quickstart - section "Regenerate gRPC code"
Related
With go mod tidy I've updated protobuf to github.com//golang/protobuf#v1.4.0
my project uses github.com/ericchiang/k8s#v1.2.0
I build binary and when I try to run it I'm getting this panic error:
panic: mismatching message name: got k8s.io.kubernetes.pkg.watch.versioned.Event, want github.com/ericchiang.k8s.watch.versioned.Event
goroutine 1 [running]:
google.golang.org/protobuf/internal/impl.legacyLoadMessageDesc(0x1f8d6c0, 0x1b85dc0, 0x1ce794f, 0x2f, 0x0, 0x0)
/home/andriy/go/pkg/mod/google.golang.org/protobuf#v1.21.0/internal/impl/legacy_message.go:136 +0x882
google.golang.org/protobuf/internal/impl.legacyLoadMessageInfo(0x1f8d6c0, 0x1b85dc0, 0x1ce794f, 0x2f, 0x4f7b57)
/home/andriy/go/pkg/mod/google.golang.org/protobuf#v1.21.0/internal/impl/legacy_message.go:48 +0xbd
google.golang.org/protobuf/internal/impl.Export.LegacyMessageTypeOf(0x1f4f0a0, 0x0, 0x1ce794f, 0x2f, 0xc000399360, 0xc0000a00d0)
/home/andriy/go/pkg/mod/google.golang.org/protobuf#v1.21.0/internal/impl/legacy_export.go:35 +0xa5
github.com/golang/protobuf/proto.RegisterType(0x1f4f0a0, 0x0, 0x1ce794f, 0x2f)
/home/andriy/go/pkg/mod/github.com/golang/protobuf#v1.4.0-rc.4.0.20200313231945-b860323f09d0/proto/registry.go:186 +0x4d
github.com/ericchiang/k8s/watch/versioned.init.0()
/home/andriy/go/pkg/mod/github.com/ericchiang/k8s#v1.2.0/watch/versioned/generated.pb.go:70 +0x4b
is there anyway to fix this, or should I downgrade protobuf to v1.3.5
I met the same problem as you,you can go directly to the error path to change the name. Replace the github.com/ericchiang.k8s.watch.versioned.Event in generated.pb.go's init() function with k8s.io.kubernetes.pkg.watch.versioned.Event.
I want to find N (for example, 16) bytes of hex in memory. In gdb, I simply do:
find /b memrange_start, memrange_end, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
And it works flawlessly. What's the equivalent in lldb? I tried:
(lldb) me find -e "0x01 0x02 0x03" -- 0x00000001050e8000 0x00000001050e9000
But it just looks for the last byte (0x03). String search using the -s parameter and "\x00\x01\x02\x03(...)\x0f" does not work either. Furthermore, when I tried various combinations, I stumbled upon this error:
(lldb) me find -e "{0x01, 0x02}" 0x7fffbe6abfc6 0x7fffbe6abfcf
error: result size larger than 8 bytes. pass a string instead
Please don't tell me I'm limited to 8 bytes with "-e" :( Did I miss some easy way to scan for the virtual address of 16 bytes of hex in memory?
My setup:
Win 10 home host, Virtualbox, Minikube.exe, Kubectl.exe, Docker Toolbox
which also create "default" VM in Virtualbox.
I need this setup for learning. I wanna do this
I have installed the Docker Toolbox which created "default" VM in Virtualbox & it's working properly.
I have used
minikube start --kubernetes-version="v1.4.0" --vm-driver="virtualbox" --show-libmachine-logs --alsologtostderr
From here
& I am getting this :
missing apiserver.crt in the minikube VM.
I do not have the localkube folder too.
I cannot manage to work together the ==>
Docker Toolbox + Minikube + Kubectl
under Win 10 Home with Virtualbox.
C:\Users\Kolly>minikube start --kubernetes-version="v1.7.5" --vm-driver="virtualbox" --alsologtostderr --v=7
C:\Users\Kolly>minikube start --alsologtostderr --v=7
Starting local Kubernetes v1.6.4 cluster...
Starting VM...
I1003 21:34:44.154518 4796 cluster.go:71] Machine exists!
Migrating to config v0
Migrating to config v1
Migrating to config v2
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x10 pc=0x8812cf]
goroutine 1 [running]:
panic(0x17498e0, 0xc042004090)
/usr/local/go/src/runtime/panic.go:500 +0x1af
k8s.io/minikube/vendor/github.com/docker/machine/libmachine/host.MigrateHostV2ToHostV3(0xc04200a400, 0xc042458000, 0x1f, 0x21f, 0x18fc74d, 0x1, 0x0)
/var/lib/jenkins/go/src/k8s.io/minikube/_gopath/src/k8s.io/minikube/vendor/github.com/docker/machine/libmachine/host/migrate_v2_v3.go:26 +0x15f
k8s.io/minikube/vendor/github.com/docker/machine/libmachine/host.MigrateHost(0xc0420f2000, 0xc042458000, 0x1f, 0x21f, 0x21f, 0x0, 0x0, 0x21)
/var/lib/jenkins/go/src/k8s.io/minikube/_gopath/src/k8s.io/minikube/vendor/github.com/docker/machine/libmachine/host/migrate.go:109 +0x950
k8s.io/minikube/vendor/github.com/docker/machine/libmachine/persist.Filestore.loadConfig(0xc042414300, 0x18, 0xc04236d460, 0x1e, 0xc04236d460, 0x1e, 0xc0420f2000, 0x21, 0x1902a95)
/var/lib/jenkins/go/src/k8s.io/minikube/_gopath/src/k8s.io/minikube/vendor/github.com/docker/machine/libmachine/persist/filestore.go:122 +0x15f
k8s.io/minikube/vendor/github.com/docker/machine/libmachine/persist.Filestore.Load(0xc042414300, 0x18, 0xc04236d460, 0x1e, 0xc04236d460, 0x1e, 0x1902a95, 0x8, 0xc0425310a0, 0x526444, ...)
/var/lib/jenkins/go/src/k8s.io/minikube/_gopath/src/k8s.io/minikube/vendor/github.com/docker/machine/libmachine/persist/filestore.go:158 +0x21e
k8s.io/minikube/pkg/minikube/machine.(*LocalClient).Load(0xc0420f6880, 0x1902a95, 0x8, 0x16b0b80, 0xc0422de260, 0x0)
/var/lib/jenkins/go/src/k8s.io/minikube/_gopath/src/k8s.io/minikube/pkg/minikube/machine/client.go:142 +0x6b
k8s.io/minikube/pkg/minikube/cluster.StartHost(0x3b8d2a0, 0xc0420f6880, 0xc04239ed40, 0x40, 0x800, 0x2, 0x4e20, 0xc0422fca10, 0xa, 0x1900e4e, ...)
/var/lib/jenkins/go/src/k8s.io/minikube/_gopath/src/k8s.io/minikube/pkg/minikube/cluster/cluster.go:72 +0x163
k8s.io/minikube/cmd/minikube/cmd.runStart.func1(0x0, 0x3bef460)
/var/lib/jenkins/go/src/k8s.io/minikube/_gopath/src/k8s.io/minikube/cmd/minikube/cmd/start.go:125 +0x83
k8s.io/minikube/pkg/util.RetryAfter(0x5, 0xc0421b24e0, 0x77359400, 0xf, 0x0)
/var/lib/jenkins/go/src/k8s.io/minikube/_gopath/src/k8s.io/minikube/pkg/util/utils.go:88 +0x6b
k8s.io/minikube/cmd/minikube/cmd.runStart(0x3be1860, 0xc042395ee0, 0x0, 0x2)
/var/lib/jenkins/go/src/k8s.io/minikube/_gopath/src/k8s.io/minikube/cmd/minikube/cmd/start.go:131 +0x76e
k8s.io/minikube/vendor/github.com/spf13/cobra.(*Command).execute(0x3be1860, 0xc042395d60, 0x2, 0x2, 0x3be1860, 0xc042395d60)
/var/lib/jenkins/go/src/k8s.io/minikube/_gopath/src/k8s.io/minikube/vendor/github.com/spf13/cobra/command.go:603 +0x440
k8s.io/minikube/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x3be0dc0, 0x3c0ec00, 0xc0425cdeb8, 0x47ed13)
/var/lib/jenkins/go/src/k8s.io/minikube/_gopath/src/k8s.io/minikube/vendor/github.com/spf13/cobra/command.go:689 +0x36e
k8s.io/minikube/vendor/github.com/spf13/cobra.(*Command).Execute(0x3be0dc0, 0x0, 0x0)
/var/lib/jenkins/go/src/k8s.io/minikube/_gopath/src/k8s.io/minikube/vendor/github.com/spf13/cobra/command.go:648 +0x32
k8s.io/minikube/cmd/minikube/cmd.Execute()
/var/lib/jenkins/go/src/k8s.io/minikube/_gopath/src/k8s.io/minikube/cmd/minikube/cmd/root.go:111 +0x34
main.main()
/var/lib/jenkins/go/src/k8s.io/minikube/_gopath/src/k8s.io/minikube/cmd/minikube/main.go:38 +0x79
I've been playing around with the HID part of IOKit lately on my Mac with a PS3 controller. I've managed to look though the sample code and connect to my controller, receive a stream of data and parse it (Everything, including the accelerometer and gyro).
However, today I decided I wanted to start setting the LEDs on the back of the device and triggering the rumble motors, but I just can't get it to work!
Looking though the sample code Apple provides for IOHID there isn't much I can see on setting things on the HID device, only receiving data. From looking on the web (for petty much half a day) I've got what I think is a working send method which uses IOHIDDeviceSetReport(). However, I can't work out what data I should be sending.
I've found several sites that list data examples:
http://www.circuitsathome.com/mcu/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-2
https://github.com/ribbotson/USB-Host/blob/master/ps3/PS3USB/ps3_usb.h
http://wiibrew.org/wiki/Sixaxis
(I know not all these examples are for between Mac an a PS3 controller)
A lot of people seem to be talking about this and even doing it (I refuse to believe no one has got this working) but I can't seem to find anything about actually how to do it that works!
I feel like I am missing a simple step here, so if anyone has any ideas, help or a solution please let me know.
Thanks.
Example Code of how I'm trying to send a report (is is returning success):
CFIndex len = 64;
uint8_t report[64] = {0x0};
IOReturn tIOReturn = IOHIDDeviceSetReport(deviceRef,
kIOHIDReportTypeOutput,
reportID,
report,
len);
This is just sending a lot of nothing (literally) but it's just an example of what I'm using just incase it's not correct.
Extra: I've also just noticed that Apples defenition of IOHIDDeviceSetReport differes from there example given.
https://developer.apple.com/library/mac/documentation/DeviceDrivers/Conceptual/HID/new_api_10_5/tn2187.html#//apple_ref/doc/uid/TP40000970-CH214-SW81
There it says report should be "address of report buffer". But...
https://developer.apple.com/library/mac/documentation/IOKit/Reference/IOHIDDevice_iokit_header_reference/Reference/reference.html#//apple_ref/doc/uid/TP40012408-CHIOHIDDevicehFunctions-DontLinkElementID_23
There it say *report (being a pointer) is "The report bytes to be sent to the device.".
there's an example at: http://www.circuitsathome.com/mcu/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-2
with the code describing the LED and Rumble control at:
https://github.com/ribbotson/USB-Host/blob/master/ps3/PS3USB/ps3_usb.cpp#L187
It seems that the bytes that you sent as report need to have a certain format:
prog_char output_01_report[] PROGMEM = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0xff, 0x27, 0x10, 0x00, 0x32, 0xff,
0x27, 0x10, 0x00, 0x32, 0xff, 0x27, 0x10, 0x00,
0x32, 0xff, 0x27, 0x10, 0x00, 0x32, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
In the LEDRumble function, these bytes are copied into buf and then buf[9] is overridden to set the LED state and the bytes from buf[1] through buf[4] are used to configure the Rumble. The the bytes are all sent to the controller.
There are some constants defined here: https://github.com/ribbotson/USB-Host/blob/master/ps3/PS3USB/ps3_usb.h#L100
#define psLED1 0x01
#define psLED2 0x02
#define psLED3 0x04
#define psLED4 0x08
#define psRumbleHigh 0x10
#define psRumbleLow 0x20
These constants are passed to the LEDRumble function as parameters.
Their example seems fine, as far as I've read it. Under these circumstances, either an uint8_t[64] variable or an uint8_t* variable will be both interpreted as a pointer to uint8_t when passed to IOHIDDeviceSetReport.
I'm on a restricted network right now, so I won't be able to help any further. But I'll try to read a little bit more about this later at home, as I also have a related project in mind. If I find out anything that can help us on this, I'll get back here to talk about it.
I'm trying to capture an event and reference a GUID to see which event it is. The code is below:
DWORD WINAPI AvisionEventProc(LPVOID lpParam){
//HANDLE hEvent = * (HANDLE *) lpParam; // This thread's read event
STINOTIFY pStiNotify;
if (debug){
wprintf(L"Avision Event\n");
}
while(true){
WaitForSingleObject(hAvisionEvent, INFINITE);
wprintf(L"Event");
pStiDevice->GetLastNotificationData(&pStiNotify);
if (pStiNotify.guidNotificationCode == GUID_STIUserDefined1){
wprintf(L"User defined 1");
}else if (pStiNotify.guidNotificationCode == GUID_STIUserDefined2){
wprintf(L"User defined 2");
}else if (pStiNotify.guidNotificationCode == GUID_STIUserDefined3){
wprintf(L"User defined 3");
}
ResetEvent(hAvisionEvent);
}
return 1;
}
This compiles just fine but I get the errors below when linking:
1>sti.obj : error LNK2001: unresolved external symbol _GUID_STIUserDefined3
1>sti.obj : error LNK2001: unresolved external symbol _GUID_STIUserDefined2
1>sti.obj : error LNK2001: unresolved external symbol _GUID_STIUserDefined1
The strange thing is that sti.h is linked in as I am pulling other constants from it. I did notice by the GUID decleration the following:
#if defined( _WIN32 ) && !defined( _NO_COM)
/*
* Class IID's
*/
// B323F8E0-2E68-11D0-90EA-00AA0060F86C
DEFINE_GUID(CLSID_Sti, 0xB323F8E0L, 0x2E68, 0x11D0, 0x90, 0xEA, 0x00, 0xAA, 0x00, 0x60, 0xF8, 0x6C);
/*
* Interface IID's
*/
// {641BD880-2DC8-11D0-90EA-00AA0060F86C}
DEFINE_GUID(IID_IStillImageW, 0x641BD880L, 0x2DC8, 0x11D0, 0x90, 0xEA, 0x00, 0xAA, 0x00, 0x60, 0xF8, 0x6C);
<snip>
/*
* Standard event GUIDs
*/
// {740D9EE6-70F1-11d1-AD10-00A02438AD48}
DEFINE_GUID(GUID_DeviceArrivedLaunch, 0x740d9ee6, 0x70f1, 0x11d1, 0xad, 0x10, 0x0, 0xa0, 0x24, 0x38, 0xad, 0x48);
<snip>
#endif
Does the "if defined" line stop the GUIDs being referenced (I am writing a win32 console app) or is there something more fundamental I have wrong here to do with a lack of understanding on GUIDs?
Thanks, in advance for your help.
Cheers,
Neil
#include <initguid.h>should be added. That will help.
The DEFINE_GUID macro either defines a named GUID as a static, or just does a forward declaration to actually be done somewhere else, depending on if #include <initguid.h> has been previously declared. Your code perhaps only have the latter, and the symbols don't have actual initialization within the project.
See:
How to avoid error "LNK2001 unresolved external" by using DEFINE_GUID
INITGUID: An Explanation
How does the DEFINE_GUID macro work? - at the bottom of the page