I am using the react-native-device-info package. DeviceInfo.getModel() and DeviceInfo.getDevice() return the same result. What's the difference between these two?
DeviceInfo.getModel() method returns the model of the device. For example, "iPhone 11 Pro" or "Samsung Galaxy S10".
DeviceInfo.getDevice() method returns the device name. For example, "iPhone11,8" or "SM-G975F".
In some cases, the result of these two methods may be the same, for example, if the device manufacturer does not have a separate device name.
Related
I'm searching for GPU information through the IO matching "IOPCIDevice" and should be nice to have info about Metal, i.e if is supported or not (I still support some years old MacPro). I see that Metal 2 has a new property called registryID and I've tried to match the IOIteratorNext, but it didn't. The code I use is just the same described here by #rsharma (credits goes to #trojanfoe) with little modifications.
So my question is: how can I use registryID to ensure is the same graphics card?
P.S. I already have an array of i/GPU that support Metal using MTLCopyAllDevices.
Given a registry entry ID, you can use IORegistryEntryIDMatching() to create a matching dictionary. You would then pass that to IOServiceGetMatchingService() (on the assumption that there's only one) or IOServiceGetMatchingServices() to retrieve the object.
I am writing a code to measure the power usage of an NVIDIA Tesla K20 GPU (Kepler architecture) periodically using the NVML API.
Variables:
nvmlReturn_t result;
nvmlEnableState_t pmmode;
nvmlDevice_t nvmlDeviceID;
unsigned int powerInt;
Basic code:
result = nvmlDeviceGetPowerManagementMode(nvmlDeviceID, &pmmode);
if (pmmode == NVML_FEATURE_ENABLED) {
result = nvmlDeviceGetPowerUsage(nvmlDeviceID, &powerInt);
}
My issue is that nvmlDeviceGetPowerManagementMode is always returning NVML_ERROR_INVALID_ARGUMENT. I checked this.
The NVML API Documentation says that NVML_ERROR_INVALID_ARGUMENT is returned when either nvmlDeviceID is invalid or pmmode is NULL.
nvmlDeviceID is definitely valid because I am able to query its properties which match with my GPU. But I don't see why I should set the value of pmmode to anything, because the documentation says that it is a Reference in which to return the current power management mode. For the record, I tried assigning an enable value to it, but the result was still the same.
I am clearly doing something wrong because other users of the system have written their own libraries using this function, and they face no problem. I am unable to contact them. What should I fix to get this function to work correctly?
The problem here was not directly in the API call - it was in the rest of the code - but the answer might be useful to others. Before attempting this solution, one must know for a fact that Power Management mode is enabled (check with nvidia-smi -q -d POWER).
In case of the invalid argument error, it is very likely that the problem lies with the nvmlDeviceID. I said I was able to query the device properties and at the time I was sure it was right, but be aware of any API calls that modify the nvmlDeviceID value later on.
For example, in this case, the following API call had some_variable as an invalid index, so nvmlDeviceID became invalid.
nvmlDeviceGetHandleByIndex(some_variable, &nvmlDeviceID);
It had to be changed to:
nvmlDeviceGetHandleByIndex(0, &nvmlDeviceID);
So the solution is to either remove all API calls that change or invalidate the value of nvmlDeviceID, or at least to ensure that any existing API call in the code does not modify the value.
I'm using the CoreWLan framework for Mac OS X to read RSSI values from an access point.
I can do it two different ways:
Using the Interface (that is connected to my network)
currentInterface = [CWInterface interface];
[currentInterface rssivalue];
Using the network:
currentInterface = [CWInterface interface];
networks = [[currentInterface scanForNetworksWithName:#"mySSID" error:nil] allObjects];
[networks[0] rssiValue];
However, it seems that these two methods (that should give the same value since the interface is connected to the network) give different results. The latter method seems to consistently give values of 3-5 dB stronger than the Interface method.
Any ideas as to why this discrepancy is happening? Which one is more "legitimate"?
The rssiValue property of the current interface (first case) gives you the aggregate rssi.
While rssiValue of the scan results (second case) gives your the rssi value for the moment of scan.
Thats why in general first one less than second one. But sometimes you can see the very low rssi values on scan results because of some interference.
And there is another thing: there can be few access points with the same ssid, and in such case you can't be sure that networks[0] will be the result for currently connected one. You should check the bssid value first.
I'm trying to measure the distance between two points (longitude, latitude). My problem is that I get different results on iOS then on Android.
I've checked it with this site and the result was that the Android values are correct.
I'm using this MapKit method to get the distance in iOS: distanceFromLocation:
Here are my test locations:
P1: 48.643798, 9.453735
P2: 49.495150, 9.782150
Distance iOS: 97717 m
Distance Android: 97673 m
How is this possible and how can I fix this?
So I was having a different issue and stumbled upon the answer to both of our questions:
On iOS you can do the following:
meters1 = [P1 distanceFromLocation:P2]
// meters1 is 97,717
meters2 = [P2 distanceFromLocation:P1]
// meters2 is 97,630
I've searched and searched but haven't been able to find a reason for the difference. Since they are the exact same points, it should show the same distance no matter which way you are traveling. I submitted it to Apple as a bug and they closed it as a duplicate but have still not fixed it. I would suggest to anyone who wants this to be fixed to also submit it as a bug.
In the meantime, the average of the two is actually the correct value:
meters = (meters1 + meters2)/2
// meters (the average of the first two) is 97,673
Apparently Android does not have this problem.
The longitude and latitude are not all that you need. You have to use the same reference model like WGS84 or ETRS89.
The earth is not an exact ellipsoid, so you need models, none of the models are entirely exact, and depending on which model you use, distances are somewhat different.
Please make sure you use the same reference for iOS and Android.
There is more than one way to calculate distance between long/lat coords based on how you compensate for the curvature of the earth, and there's no right or wrong approach. Most likely the two platforms use a slightly different model.
Here are some formulae for calculating it yourself. http://www.movable-type.co.uk/scripts/latlong.html
If you absolutely need them to be the same, just implement your own calculation using one of these formulae, then you can ensure you get the same result on both platforms.
I am trying to detect objects in image on an iphone app.
I am using the cvMatchTemplate function, I manage to see some patterns returned by the cvMatchTemplate function (I chose CV_TM_CCOEFF_NORMED).
Positive Results (result image is 163x371):
http://encryptedpixel.files.wordpress.com/2011/07/photo-13-7-11-11-52-19-am.jpeg
cvMinMaxLoc returns: min (102,244) max(11,210)
The min point is making some sense here, the position of the dark spot is really 102,244 in the result image of 163x371
Negative Results:
cvMinMaxLoc returns: min (114,370) max(0,0)
This is not making sense, there is totally no results, why is there still a min point at 114,370?
I need to know how to analyze these results programatically so that I can say "Hey I found the object!" in objectiveC for iPhone app?
Thanks!
cvMinMaxLoc will always return the position of the minimum and maximum values of their input. It only "doesn't make sense" in your particular application. You should check the value at the returned position for the minimum and do something like threshold it to see if that's a probable match for your template. A template match will yield a very low or a very high value, depending on the method you chose.