Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryDevice fails with error code 1167 (0x48F, ERROR_DEVICE_NOT_CONNECTED) #284

Closed
d8ahazard opened this issue Feb 28, 2021 · 8 comments · Fixed by #285
Closed

QueryDevice fails with error code 1167 (0x48F, ERROR_DEVICE_NOT_CONNECTED) #284

d8ahazard opened this issue Feb 28, 2021 · 8 comments · Fixed by #285
Assignees
Labels
Milestone

Comments

@d8ahazard
Copy link

d8ahazard commented Feb 28, 2021

Trying to loop through all the various GUIDS and see if anything is connected, and I get this error with every query to the API.

Here's the code I'm running:

var props = typeof(Devices).GetFields(BindingFlags.Public | 
			                                              BindingFlags.Static |
			                                              BindingFlags.FlattenHierarchy)
				.ToList();
			Log.Debug("We have " + props.Count + " props.");
			foreach (var prop in props) {
				var guid = prop.GetValue(null).ToString();
				if (guid != null) {
					var guidVal = Guid.Parse(guid);
					Log.Debug("Prop: " + guid);
					try {
						Log.Debug("Checking GUID validity...");
						var valid = Devices.IsValidId(guidVal);
						Log.Debug("Not dead yet.");
						if (valid) {
							Log.Debug("Querying...");
							var info = await _chroma.QueryAsync(guidVal);
							Log.Debug("Still not dead...");
							if (info != null) {
								Log.Debug("Device discovered!: " + info.Description);
							} else {
								Log.Debug("Device is null...");
							}
						} else {
							Log.Debug("Guid is invalid.");
						}
					} catch (Exception e) {
						Log.Warning("Exception: " + e.Message);
					}	
				}
				
			}

And here's the log output:

[20:32:40 DBG][RazerDiscovery][CheckDevices] Prop: 803378c1-cc48-4970-8539-d828cc1d420a
[20:32:40 DBG][RazerDiscovery][CheckDevices] Checking GUID validity...
[20:32:40 DBG][RazerDiscovery][CheckDevices] Not dead yet.
[20:32:40 DBG][RazerDiscovery][CheckDevices] Querying...
[20:32:40 DBG][SerilogLogger][Log] Information for 803378c1-cc48-4970-8539-d828cc1d420a requested
[20:32:40 WRN][RazerDiscovery][CheckDevices] Exception: Call to native Chroma SDK function QueryDevice failed with error: Unknown: Unknown. (1167)

Instead, I'd obviously expect to get deviceinfo and the option to check if they're connected.

Any suggestions?

I'm checking that the Chroma SDK is installed before, and those checks return fine as well:

[20:32:40 DBG][SerilogLogger][Log] Creating new native IChroma instance
[20:32:40 INF][SerilogLogger][Log] Loading native Chroma SDK
[20:32:40 DBG][SerilogLogger][Log] Native Chroma SDK loaded at pointer value "140713887989760"
[20:32:40 DBG][SerilogLogger][Log] Loading native SDK function delegates
[20:32:40 DBG][SerilogLogger][Log] Function delegates loaded
[20:32:40 DBG][SerilogLogger][Log] Uninitializing current IChroma instance
[20:32:40 INF][SerilogLogger][Log] Chroma is initializing.
[20:32:40 DBG][SerilogLogger][Log] Retrieving SDK version
[20:32:40 INF][SerilogLogger][Log] Colore is running against SDK version "3.17.2".
[20:32:40 DBG][SerilogLogger][Log] Calling SDK Init function
[20:32:41 DBG][SerilogLogger][Log] Resetting _registeredHandle
[20:32:41 DBG][RazerDiscovery][CheckDevices] Razer SDK Loaded (6.0.0.14)
[20:32:41 DBG][RazerDiscovery][CheckDevices] We have 24 props.
@Sharparam
Copy link
Member

Error code 1167 (0x48F) is ERROR_DEVICE_NOT_CONNECTED (reference).

Are the devices you are querying connected to the system?

Regardless, the SDK shouldn't throw an error code if an unconnected device is queried, so that is most definitely strange.

@d8ahazard
Copy link
Author

d8ahazard commented Feb 28, 2021 via email

@Sharparam
Copy link
Member

I get the same results on my machine.

A query on Blackwidow which I have connected works fine. A query on Blade Stealth which I do not have fails with the 1167 error. This at least confirms the suspicion about it failing on devices that are not connected, but it's not the behaviour I'd expect from the SDK.

I don't have an official channel to Razer for questions at the moment, but I'll see if I can get a response from the community Discord (which has some Razer staff on it).

@Sharparam Sharparam added the SDK label Feb 28, 2021
@d8ahazard
Copy link
Author

d8ahazard commented Feb 28, 2021 via email

@d8ahazard
Copy link
Author

Also, FWIW, if the SDK wasn't throwing an exception on a disconnected device (or you ignore the exception), the attached code can be used to enumerate all device GUIDs from Devices and check for connectivity, possibly to implement #145

@Sharparam
Copy link
Member

If they come back and say that the error is intended, I'll update the library to detect that and return the struct with Connected set to false. That way the caller (users of the library) don't have to manually handle this error case.

@d8ahazard
Copy link
Author

If they come back and say that the error is intended, I'll update the library to detect that and return the struct with Connected set to false. That way the caller (users of the library) don't have to manually handle this error case.

Looking at the SDK reference, I think this is the designed behavior...

https://assets.razerzone.com/dev_portal/C%2B%2B/html/en/_rz_chroma_s_d_k_8h.html#a7583d0e872e09dc181e57a818ed576b8

@Sharparam
Copy link
Member

They did at some point change the Connected on DEVICE_INFO_TYPE from being a boolean to being a DWORD. Presumably it was around the same time they changed the behaviour for devices that are not connected. But hopefully I can get some official word on it as well, there doesn't seem to be a changelog for the SDK.

@Sharparam Sharparam changed the title Exception: Call to native Chroma SDK function QueryDevice failed with error: Unknown: Unknown. (1167) QueryDevice fails with error code 1167 (0x48F, ERROR_DEVICE_NOT_CONNECTED) Feb 28, 2021
@Sharparam Sharparam added this to the v6.0 milestone Feb 28, 2021
@Sharparam Sharparam self-assigned this Feb 28, 2021
Sharparam added a commit that referenced this issue Mar 1, 2021
If the SDK returns the ERROR_DEVICE_NOT_CONNECTED error when calling
the QueryDevice API, do not throw a NativeCallException but instead
detect this error and return a device info struct where the connected
count is set to zero.

A new enum member "Unknown" is added to the DeviceType enumeration
to cover this use case.

Fixes #284.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants