I2C Disabled using Lightning Provider (DMMD) in Windows 10 IoT / Raspberry Pi 2 - windowsiot

I just started looking into the Lightning provider and the first thing I tried by I2C and I found an issue. The I2C device (returned by DeviceInformation) shows it as DISABLED but when using the Inbox Driver shows as ENABLED.
I have a RBPi2 B with Windows 10 IoT 10.0.14393.67
I enabled DMMD Driver and created a simple program that makes reference to:
Microsoft.IoT.Lightning: 1.1.0
Microsoft.IoT.SDKFromArduino: 1.1.1
Also enabled the extensions:
Windows Desktop Extensions for the UWP: 10.0.14393.0
Windows IoT Extensions for the UWP: 10.0.14393.0
Modified Package.aspxmanifest with
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10"
IgnorableNamespaces="uap mp iot">
....
<Capabilities>
<Capability Name="internetClient" />
<iot:Capability Name="lowLevelDevices" />
<DeviceCapability Name="109b86ad-f53d-4b76-aa5f-821e2ddf2141"/>
</Capabilities>
</Package>
And with the following code:
public MainPage()
{
this.InitializeComponent();
if (LightningProvider.IsLightningEnabled)
{
LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider();
}
CreateAsync();
}
private async Task CreateAsync()
{
var aqs = I2cDevice.GetDeviceSelector("I2C1");
var i2cDevices = await DeviceInformation.FindAllAsync(aqs);
var i2cDevices_ManualAQS = await DeviceInformation.FindAllAsync("System.Devices.InterfaceClassGuid:=\"{a11ee3c6-8421-4202-a3e7-b91ff90188e4}\" AND System.DeviceInterface.Spb.ControllerFriendlyName:=\"I2C1\"");
var allDevices = await DeviceInformation.FindAllAsync();
foreach (var device in allDevices)
{
System.Diagnostics.Debug.WriteLine($"{device.Id} - {device.Name}");
}
}
i2cDevices does not return any devices, but i2cDevices_ManualAQS returns 1 which is DISABLED (I manually changed the AQS to include enabled and disabled devices) and the allDevices shows there is a I2C1 device in it (\\?\ACPI#MSFT8000#1#{a11ee3c6-8421-4202-a3e7-b91ff90188e4}\I2C1)
If I changed the driver to Inbox Driver i2cDevices has 1 device and it is ENABLED.
So, either DeviceInformation is returning incorrect data or the I2C device is not enable with using Lightning.
I have already posted this message to the "issues" section for that repo, but posted here too just in case I was doing it wrong and it was not a bug.
Any ideas would be appreciated.
Thank you!

Related

In Selenium webdriver, for remote Firefox how to use OSS bridge instead of w3c bridge for handshaking

I am using selenoid for remote browser testing in ruby.
In that I am using 'selenium-webdriver', 'capybara', 'rspec' for automation. And I am using attach_file method for uploading file to browser
I want to upload file on Firefox and Chrome browser but it raises error on both;
In chrome
Selenium::WebDriver::Error::UnknownCommandError: unknown command: unknown command: session/***8d32e045e3***/se/file
In firefox
unexpected token at 'HTTP method not allowed'
So After searching I found the solution for chrome which is to set w3c option false in caps['goog:chromeOptions'] > caps['goog:chromeOptions'] = {w3c: false}
So now chrome is using OSS bridge for handshaking but I don't know how to do it in Firefox. Similar solution is not available for Firefox.
My browser capabilities are following:
if ENV['BROWSER'] == 'firefox'
caps = Selenium::WebDriver::Remote::Capabilities.new
caps['browserName'] = 'firefox'
# caps['moz:firefoxOptions'] = {w3c: false} ## It is not working
else
caps = Selenium::WebDriver::Remote::Capabilities.new
caps["browserName"] = "chrome"
caps["version"] = "81.0"
caps['goog:chromeOptions'] = {w3c: false}
end
caps["enableVNC"] = true
caps["screenResolution"] = "1280x800"
caps['sessionTimeout'] = '15m'
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, browser: :remote,
:desired_capabilities => caps,
:url => ENV["REMOTE_URL"] || "http://*.*.*.*:4444/wd/hub"
)
end
Capybara.configure do |config|
config.default_driver = :selenium
end
I have found the problem. There is bug in selenium server which run on java so I have to change my selenium-webdriver gem version 3.142.7 and monkey-patch.
You can find more information here about the bug and resolution.
For now I have to change my gem and monkey patch the selenium-webdriver-3.142.7\lib\selenium\webdriver\remote\w3c\commands.rb file. check for below line which is on line no 150.
upload_file: [:post, 'session/:session_id/se/file']
and update it to
upload_file: [:post, 'session/:session_id/file']
i had a similar issue with rails 7. the issue is connected with the w3c standard. the core problem is that the webdriver for chrome uses a non-w3c standard url for handling file uploads. when uploading a file, the webdriver uses the /se/file url path to upload. this path is only supported by the selenium server. subsequently, the docker image provided by selenium works fine. yet, if we use chromedriver, the upload fails. more info.
we can solve this, by forcing the webdriver to use the standard-compliant url by overriding the :upload_file key in Selenium::WebDriver::Remote::Bridge::COMMANDS. since, the initialization of this the COMMANDS constant does not happen when the module is loaded, we can override the attach_file method to make sure the constant is set correctly. here the hacky code:
module Capybara::Node::Actions
alias_method :original_attach_file, :attach_file
def attach_file(*args, **kwargs)
implement_hacky_fix_for_file_uploads_with_chromedriver
original_attach_file(*args, **kwargs)
end
def implement_hacky_fix_for_file_uploads_with_chromedriver
return if #hacky_fix_implemented
original_verbose, $VERBOSE = $VERBOSE, nil # ignore warnings
cmds = Selenium::WebDriver::Remote::Bridge::COMMANDS.dup
cmds[:upload_file] = [:post, "session/:session_id/file"]
Selenium::WebDriver::Remote::Bridge.const_set(:COMMANDS, cmds)
$VERBOSE = original_verbose
#hacky_fix_implemented = true
end
end
In Firefox images we support /session/<id>/file API by adding Selenoid binary which emulates this API instead of Geckodriver (which does not implement it).

Unable to execute appium teston real iOS device over wifi (without cable) but same script works fine cable connection

I want to execute my appium testcases on real iOS device over wifi (without connecting via cable).
I have tried "Connect via network" option in Devices and Simulators. But its just launching the app and closing automatically. Testcase is not executing.Same testcase is executing correctly via cable(if passcode is turn off).
xCode verison = 10.1
device iOS verison = 12.4.2
#BeforeTest
public void applaunch() throws MalformedURLException {
dc.setCapability("platformName", "iOS");
dc.setCapability("deviceName", "My iPhone");
dc.setCapability("automationName", "XCUITest");
dc.setCapability("noReset", true);
dc.setCapability("xcodeOrgId", "HDYDHGKBDKGJG");
dc.setCapability("xcodeSigningId", "iPhone Developer");
dc.setCapability("platformVersion", "12.4.2");
dc.setCapability("useNewWDA", "true");
//dc.setCapability("reportDirectory", reportDirectory);
//dc.setCapability("reportFormat", reportFormat);
dc.setCapability("testName", testName);
dc.setCapability(MobileCapabilityType.UDID, "Vhduysshs9af42cad204240fdfgfdgdgyjdhdhgdf");
dc.setCapability("bundleId", "com.estapp.pro.apptest");
driver = new IOSDriver<IOSElement>(new URL("http://127.0.0.1:4723/wd/hub"), dc);
}
#Test
public void test() throws Exception{
driver.findElementByXPath("//*[#name='More']").click();// Click on More button
}
#AfterTest
public void CloseApp() {
driver.closeApp();
}
You need to go to xcode to enable the wifi "connect via network" checkbox.
Input this in your terminal
idevice_id -l
if you see the real device uuid appears , it means you are successful connecting with wifi. You can execute your script from here.

Setting downloads directory for chrome driver suddenly stopped working after upgrade

After I've upgraded my project to use latest java selenium webdriver 3.7.1 and latest chrome driver 2.33 I noticed that my tests dealing with Excel export started to fail.
After debugging I see that for some reasons downloads directory is not being set to custom location and instead the default one is used. Nothing shows up in logs or whatsoever.
Any help appreciated.
Setting downloads directory is like usual:
val prefs = Map(
"profile.default_content_settings.popups" -> Integer.valueOf(0),
"download.default_directory" -> downloadsDir,
"credentials_enable_service" -> false,
"profile.password_manager_enabled" -> false
)
val chromeOptions:ChromeOptions = new ChromeOptions()
chromeOptions.setExperimentalOption("prefs", prefs)
val d = new ChromeDriver(chromeOptions)
I use WebDriver 3.7.1 and Chromedriver 2.33 and of course Chrome v.62 (try check Your Version of Chrome), and I can download files.
I'm using folder
public static String javaIoTmpDir = System.getProperty("java.io.tmpdir")+"/autotest/";
and I create/clean it with script in TestNG annotation: #BeforeSuite
File theDir = new File(javaIoTmpDir);
// if the directory does not exist, create it
if (!theDir.exists()) {
System.out.println("creating directory: " + theDir.getName());
boolean result = false;
try{
theDir.mkdir();
result = true;
}
catch(SecurityException se){
se.printStackTrace();
}
if(result) {
System.out.println(javaIoTmpDir+" created");
}
}
FileUtils.cleanDirectory(new File(javaIoTmpDir));
}

Using Xbee java API

I am trying to turn Xbee's pin on and off with a diffrent xbee(XB24-ZB) by using the java api library.
This is my system cunfig:
1.XBEE - Routher API (COM7)
2.XBEE - Coordinator API (COM17)
Two of them are with the same ID.
I am using the exmaple code:
XBee xbee = new XBee();
xbee.open("COM17", 9600);
// this is the Serial High (SH) + Serial Low (SL) of the remote XBee
XBeeAddress64 addr64 = new XBeeAddress64("00 13 A2 00 40 A7 3E 7E");
// Turn on DIO0 (Pin 20)
RemoteAtRequest request = new RemoteAtRequest(addr64, "D0", new int[XBeePin.Capability.DIGITAL_OUTPUT_HIGH.getValue()]);
xbee.sendAsynchronous(request);
RemoteAtResponse response = (RemoteAtResponse) xbee.getResponse();
if (response.isOk()) {
System.out.println("Successfully turned on DIO0");
} else {
System.out.println("Attempt to turn on DIO0 failed. Status: " + response.getStatus());
}
// shutdown the serial port and associated threads
xbee.close();
When I run this block of code the DI0 on xbee #1 does change, but to 0(disabled) and not to 5.
I also get this error:
log4j:WARN No appenders could be found for logger (com.rapplogic.xbee.api.InputStreamThread).
log4j:WARN No appenders could be found for logger (com.rapplogic.xbee.api.InputStreamThread).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN Please initialize the log4j system properly.
The "AP" is set to 2 as said and the response I get is good.
So what am I missing here?
Thank you
Try to use these imports:
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
Add this line to you class:
private final static Logger log = Logger.getLogger(YourClass.class);
And, inside the main(), put this line beginning:
PropertyConfigurator.configure("log4j.properties");
I took it from the code examples inside the API src folder, and with it my programs are running just fine.

phantomjs page.evaluate to scrape "resultStats" from http://www.google.com/search?q=site:%s works in local server but not production server

Using phantomjs page.evaluate to extract "resultStats" (div id) from http://www.google.com/search/?q=site:%s works on my local server but not on production server.
NOTE: I'm using the latest phantomjs 1.9.7, however I experienced the same issue with the previous version 1.9.6
NOTE: Phantomjs page.render (on Google home page as well as any other domain name) is working on both servers and creates nice screenshots.
On my production server (Debian stable 7.3 #linode.com) the PHP code below for a top level domain name as the "$url" returns:
TypeError: 'null' is not an object (evaluating 'document.getElementById('resultStats').textContent') phantomjs://webpage.evaluate():2 phantomjs://webpage.evaluate():3 phantomjs://webpage.evaluate():3 null
On my local server (debian testing) the PHP code below for the same "$url" returns:
About 43 results
This happens with any domain name/url I use as the argument - I've tested it on dozens.
What might cause this to occur in my remote production server and not my local server?
gsiteindex.js
var page = require('webpage').create(), site;
var site = phantom.args[0];
page.open("https://www.google.com/search?q=site:" + site, function (status) {
var result = page.evaluate(function () {
return document.getElementById('resultStats').textContent;
});
console.info(result);
phantom.exit();
});
.php
$phantomjs = "phantomjs";
$script = "gsiteindex.js";
$site = $url;
$command = "$phantomjs $script $site";
$googlestring = shell_exec($command);
echo $googlestring;
die();
Well, nrabinowitz was right. I tested it more on my own server using proxies, most timed out, some returned the above error, and a couple returned correct results (well I assume they were correct based on the location the IP address of the proxy - because the figures were a little different than using my ISPs public IP address (calif., USA)).
So it's simply a matter of google blocking certain types of requests from certain IP addresses.
Thanks again for the comment.
Incleude header with user-agent e.g.
header = {'user-asgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64;
rv:68.0) Gecko/20100101 Firefox/68.0'}
Withuot user agent you get googles gefault style page without resultStats a also had this issue and adding header helped
Default google search page looks like this
enter image description here

Resources