pwm-backlight driver not being probed in u-boot - beagleboneblack

I'm trying to get my PWM working on a custom am33x board (same beagle-bone black target). For some reason I don't see the pwm-backlight driver being probed and thus no PWM as indicated on my scope. Here are my relevant source files:
dts snippet:
/dts-v1/;
#include "am33xx.dtsi"
#include <dt-bindings/interrupt-controller/irq.h>
/ {
model = "test";
compatible = "ti,am33xx";
chosen {
stdout-path = &uart0;
};
backlight: backlight {
status = "okay";
compatible = "pwm-backlight";
pwms = <&ehrpwm1 0 10000 0>;
brightness-levels = <0 10 20 30 40 50 60 70 80 90 99>;
default-brightness-level = <6>;
};
};
&am33xx_pinmux {
ehrpwm1_pins: pinmux-ehrpwm1-pins {
pinctrl-single,pins = <
AM33XX_IOPAD(0x848, PIN_OUTPUT_PULLDOWN | MUX_MODE6) /* gpmc_a2.ehrpwm1a */
>;
};
};
&ehrpwm1 {
u-boot,dm-spl;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&ehrpwm1_pins>;
};
defconfig
CONFIG_DM=y
CONFIG_CMD_DM=y
CONFIG_DM_VIDEO=y
CONFIG_DM_PWM=y
CONFIG_BACKLIGHT_PWM=y
pwm-backlight driver info
config BACKLIGHT_PWM
bool "Generic PWM based Backlight Driver"
depends on DM_VIDEO && DM_PWM
default y
help
If you have a LCD backlight adjustable by PWM, say Y to enable
this driver.
This driver can be use with "simple-panel" and
it understands the standard device tree
(leds/backlight/pwm-backlight.txt)
(linux version)
https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/leds/backlight/pwm-backlight.txt
and when I interrupt u-boot and use dm tree you can see that its not probed. Why?
=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------
root 0 [ + ] root_driver root_driver
simple_bus 0 [ + ] generic_simple_bus |-- ocp
simple_bus 1 [ ] generic_simple_bus | |-- l4_wkup#44c00000
simple_bus 2 [ ] generic_simple_bus | | |-- prcm#200000
simple_bus 3 [ ] generic_simple_bus | | `-- scm#210000
syscon 0 [ ] syscon | | `-- scm_conf#0
gpio 0 [ ] gpio_omap | |-- gpio#44e07000
gpio 1 [ ] gpio_omap | |-- gpio#4804c000
gpio 2 [ ] gpio_omap | |-- gpio#481ac000
gpio 3 [ ] gpio_omap | |-- gpio#481ae000
serial 0 [ + ] omap_serial | |-- serial#44e09000
mmc 0 [ + ] omap_hsmmc | |-- mmc#481d8000
timer 0 [ + ] omap_timer | |-- timer#48040000
timer 1 [ ] omap_timer | |-- timer#48042000
timer 2 [ ] omap_timer | |-- timer#48044000
timer 3 [ ] omap_timer | |-- timer#48046000
timer 4 [ ] omap_timer | |-- timer#48048000
timer 5 [ ] omap_timer | |-- timer#4804a000
misc 0 [ + ] ti-musb-wrapper | `-- usb#47400000
usb 0 [ + ] ti-musb-peripheral | `-- usb#47401000
eth 0 [ + ] usb_ether | `-- usb_ether
backlight 0 [ ] pwm_backlight `-- backlight

Related

specflow external data using json with many property

I am trying to migrate from specflow excel to using a json data file and the external data plugin
Related to Specflow - using data from external file in feature file is there a walkthrough to setup a feature file, and json data file with new #property approach to data?
I have a Specflow feature like this, which originally came from Specflow Excel.
Feature: EndToEndId
Scenario Outline: Single Payment
Given a client <clientNo> called <cName>
And a broker <bName> with book ref <bRef>
When a deal to <buyOrSell> an amount <fromAmt> of <ccy1> for <ccy2> for value <vDate> at client rate <cRate> and bank rate <bRate>
Then create a deal <dealNo> with client amt <toCAmt> and cover amt <coverAmt> and PnL <PnL> and profit rate <pRate> and <bYes>
And add beneficiary <benName> and country <ctry> and pay type <payType> and charge <charge> and <abYes>
When a credit file <c1> with <c1Name> for <c1Amt> <c1Ccy> for value <c1Date> with ref <EndToEndId1>
Then CreditNotice gets <fIn1Type> for client <fIn1Client>
Examples:
| case | clientNo | cName | bName | bRef | buyOrSell | fromAmt | ccy1 | ccy2 | vDate | cRate | bRate | dealNo | toCAmt | coverAmt | PnL | pRate | bYes | benName | ctry | payType | charge | abYes | c1 | c1Name | c1Amt | c1Ccy | c1Date | EndToEndId1 | fIn1Type | fIn1Client |
| T1: 99549 ###### | 99549 | Gherkin Test | MERCURY | 01W3RG5638 | SELL | 100000 | EUR | GBP | SP | 0.89435 | 0.89935 | ###### | 89435 | 89935 | 500 | 1 | yes | Gherkin Ben | GB | CHAPS | NONE | yes | 99549 | Gherkin Test | 100000 | EUR | SP | 99549 ###### | FullFundsIn | Gherkin Test |
To use the with a json file for the data, am I going to need to define each property again like this:
#property:clientNo=clientNo
#property:cName=cName
#property:bName=bName
and a json data file like this:
{
"case": "T-9: 99549 ######",
"clientNo": "99549",
"cName": "Gherkin Test",
"bName": "MERCURY",
"bRef": "01W3RG5638",
"buyOrSell": "SELL",
"fromAmt": "100,000",
"ccy1": "EUR",
"ccy2": "GBP",
"vDate": "SP",
"cRate": " 0.894350 ",
"bRate": " 0.894350 ",
"dealNo": "######",
"toCAmt": "89,435.00",
"coverAmt": "89,435.00",
"PnL": "0.00",
"pRate": " 1.000000 ",
"bYes": " yes ",
"benName": "Gherkin Ben",
"ctry": "GB",
"payType": "CHAPS",
"charge": "NONE",
"abYes": "yes",
"c1": "99549",
"c1Name": "Gherkin Test",
"c1Amt": "100,000",
"c1Ccy": "EUR",
"c1Date": "SP",
"EndToEndId1": "99549 ######",
"fIn1Type": "FullFundsIn",
"fIn1Client": "Gherkin Test"
},
{
"case": "T-8: 1234 1234",
"clientNo": "99549",
"cName": "Gherkin Test",
"bName": "JUPITER",
"bRef": "01W3RG5639",
"buyOrSell": "SELL",
"fromAmt": "200,000",
"ccy1": "EUR",
"ccy2": "GBP",
"vDate": "SP",
"cRate": " 0.894350 ",
"bRate": " 0.894350 ",
"dealNo": "######",
"toCAmt": "178,870.00",
"coverAmt": "178,870.00",
"PnL": "0.00",
"pRate": " 1.000000 ",
"bYes": " yes ",
"benName": "Gherkin Ben",
"ctry": "GB",
"payType": "FASTER",
"charge": "NONE",
"abYes": "yes",
"c1": "99549",
"c1Name": "Gherkin Test",
"c1Amt": "200,000",
"c1Ccy": "EUR",
"c1Date": "SP",
"EndToEndId1": "1234 1234",
"fIn1Type": "BankRec",
"fIn1Client": "Gherkin Test"
}
Thanks for some pointers on how to get the json data into the specflow feature file.
The SpecFlow.ExternalData plugin is currently limited to a single parameter.
Please upvote the feature request at https://support.specflow.org/hc/en-us/community/posts/360015106078-Allow-multiple-parameters-to-be-used-with-External-Data-plugin to get this higher in our backlog priority.
There is a separate plugin called Specflow.Contrib.JsonData as part of Nuget packages which accepts JSON data as an input for specflow scenarios. It is an extension to the Specflow.ExternalData plugin. It also accepts multiple properties. Check out https://libraries.io/nuget/SpecFlow.Contrib.JsonData.

Can you use Web3.js directly in a Rails 6 app using Webpacker?

How can you interact with a local Truffle Ganache blockchain through a Rails 6 app? I have prototyped the FixedSupplyToken app in vanilla javascript, and everything works as expected. Next, I try to move it into a Rails 6 app. I am nervous about using the Ruby gems (ethereum.rb - looking for someone to take over maintenance, others seem abandoned). I am wondering if you can you import web3.js directly into Rails 6 using Webpacker?
I created a new Rails 6 app and added the following:
yarn add web3
yarn add truffle-contract
Both installed and showed up in the package.json:
{
"name": "app",
"private": true,
"dependencies": {
"#fortawesome/fontawesome-free": "^5.12.0",
"#fortawesome/free-brands-svg-icons": "^5.12.0",
"#fortawesome/free-regular-svg-icons": "^5.12.0",
"#fortawesome/free-solid-svg-icons": "^5.12.0",
"#rails/actioncable": "^6.0.0",
"#rails/actiontext": "^6.0.2-1",
"#rails/activestorage": "^6.0.0",
"#rails/ujs": "^6.0.0",
"#rails/webpacker": "4.2.2",
"bootstrap": "^4.4.1",
"bootswatch": "^4.4.1",
"chart.js": "^2.9.3",
"chartkick": "^3.2.0",
"datatables.net-bs4": "^1.10.20",
"datatables.net-buttons-bs4": "^1.6.1",
"datatables.net-responsive-bs4": "^2.2.3",
"datatables.net-select-bs4": "^1.3.1",
"flatpickr": "^4.6.3",
"jquery": "^3.4.1",
"popper.js": "^1.16.0",
"trix": "^1.0.0",
"truffle-contract": "^4.0.31",
"turbolinks": "^5.2.0",
"vue": "^2.6.11",
"web3": "^1.2.5-rc.0"
},
"version": "0.1.0",
"devDependencies": {
"webpack-dev-server": "^3.10.1"
}
}
I then added this to app/javascript/packs (web3/index.js):
// Import libraries we need.
import Web3 from 'web3';
import contract from 'truffle-contract';
// Import our contract artifacts and turn them into usable abstractions.
import token_artifacts from './FixedSupplyToken.json';
// TokenContract is our usable abstraction, which we'll use through the code below.
var TokenContract = contract(token_artifacts);
// The following code is to interact with contracts.
var accounts;
var account;
window.App = {
start: function() {
var self = this;
// Bootstrap the TokenContract abstraction for Use.
TokenContract.setProvider(web3.currentProvider);
// Get the initial account balance so it can be displayed.
web3.eth.getAccounts(function (err, accs) {
if (err != null) {
alert("There was an error fetching your accounts.");
return;
}
if (accs.length == 0) {
alert("Couldn't get any accounts! Make sure your Ethereum client is configured correctly.");
return;
}
accounts = accs;
account = accounts[0];
});
},
initManageToken: function() {
App.updateTokenBalance();
App.watchTokenEvents();
},
updateTokenBalance: function() {
var tokenInstance;
TokenContract.deployed().then(function (instance) {
tokenInstance = instance;
return tokenInstance.balanceOf.call(account);
}).then(function (value) {
console.log(value);
var balance_element = document.getElementById("balanceTokenInToken");
balance_element.innerHTML = value.valueOf();
}).catch(function (e) {
console.log(e);
App.setStatus("Error getting balance; see log.");
});
},
watchTokenEvents: function() {
var tokenInstance;
TokenContract.deployed().then(function (instance) {
tokenInstance = instance;
tokenInstance.allEvents({}, {fromBlock: 0, toBlock: 'latest'}).watch(function (error, result) {
var alertbox = document.createElement("div");
alertbox.setAttribute("class", "alert alert-info alert-dismissible");
var closeBtn = document.createElement("button");
closeBtn.setAttribute("type", "button");
closeBtn.setAttribute("class", "close");
closeBtn.setAttribute("data-dismiss", "alert");
closeBtn.innerHTML = "<span>×</span>";
alertbox.appendChild(closeBtn);
var eventTitle = document.createElement("div");
eventTitle.innerHTML = '<strong>New Event: ' + result.event + '</strong>';
alertbox.appendChild(eventTitle);
var argsBox = document.createElement("textarea");
argsBox.setAttribute("class", "form-control");
argsBox.innerText = JSON.stringify(result.args);
alertbox.appendChild(argsBox);
document.getElementById("tokenEvents").appendChild(alertbox);
//document.getElementById("tokenEvents").innerHTML += '<div class="alert alert-info alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button><div></div><div>Args: '+JSON.stringify(result.args) + '</div></div>';
});
}).catch(function (e) {
console.log(e);
App.setStatus("Error getting balance; see log.");
});
},
sendToken: function() {
var amount = parseInt(document.getElementById("inputAmountSendToken").value);
var receiver = document.getElementById("inputBeneficiarySendToken").value;
App.setStatus("Initiating transaction... (please wait)");
var tokenInstance;
return TokenContract.deployed().then(function (instance) {
tokenInstance = instance;
return tokenInstance.transfer(receiver, amount, {from: account});
}).then(function () {
App.setStatus("Transaction complete!");
App.updateTokenBalance();
}).catch(function (e) {
console.log(e);
self.setStatus("Error sending coin; see log.");
});
},
allowanceToken: function() {
var self = this;
var amount = parseInt(document.getElementById("inputAmountAllowanceToken").value);
var receiver = document.getElementById("inputBeneficiaryAllowanceToken").value;
this.setStatus("Initiating transaction... (please wait)");
var tokenInstance;
return TokenContract.deployed().then(function (instance) {
tokenInstance = instance;
return tokenInstance.approve(receiver, amount, {from: account});
}).then(function () {
self.setStatus("Transaction complete!");
App.updateTokenBalance();
}).catch(function (e) {
console.log(e);
self.setStatus("Error sending coin; see log.");
});
}
};
document.addEventListener('load', function() {
// Checking if Web3 has been injected by the browser (Mist/MetaMask)
if (typeof web3 !== 'undefined') {
console.warn("Using web3 detected from external source. If you find that your accounts don't appear or you have 0 MetaCoin, ensure you've configured that source properly. If using MetaMask, see the following link. Feel free to delete this warning. :) http://truffleframework.com/tutorials/truffle-and-metamask")
// Use Mist/MetaMask's provider
window.web3 = new Web3(web3.currentProvider);
} else {
console.warn("No web3 detected. Falling back to http://localhost:8545. You should remove this fallback when you deploy live, as it's inherently insecure. Consider switching to Metamask for development. More info here: http://truffleframework.com/tutorials/truffle-and-metamask");
// fallback - use your fallback strategy (local node / hosted node + in-dapp id mgmt / fail)
window.web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:7545"));
}
});
Then, when I launch the Rails 6 app in a Docker container, everything seems fine until the webpack-dev-server attempts to compile the assets, and it throws this error:
webpack-dev-server | ℹ 「wdm」: Compiling...
webpack-dev-server | ✖ 「wdm」: Hash: 8531025c7b3abcc5d778
webpack-dev-server | Version: webpack 4.41.5
webpack-dev-server | Time: 1963ms
webpack-dev-server | Built at: 01/21/2020 4:46:26 PM
webpack-dev-server | Asset Size Chunks Chunk Names
webpack-dev-server | js/application-8df32eacba8ebdbf7444.js 6.49 MiB application [emitted] [immutable] application
webpack-dev-server | js/application-8df32eacba8ebdbf7444.js.map 6.93 MiB application [emitted] [dev] application
webpack-dev-server | manifest.json 1.9 KiB [emitted]
webpack-dev-server | media/images/Logo_medlarge-e2a09f85c0c6ed39d81ce70b3bd44e51.png 130 KiB
webpack-dev-server | media/images/pdf_icon-c00c8db0462b60773a72302f7b9d456b.png 1.36 KiB
webpack-dev-server | media/webfonts/fa-brands-400-088a34f7.eot 129 KiB
webpack-dev-server | media/webfonts/fa-brands-400-273dc9bf.ttf 129 KiB
webpack-dev-server | media/webfonts/fa-brands-400-822d94f1.woff2 74.2 KiB
webpack-dev-server | media/webfonts/fa-brands-400-d7229311.svg 692 KiB
webpack-dev-server | media/webfonts/fa-brands-400-f4920c94.woff 87 KiB
webpack-dev-server | media/webfonts/fa-regular-400-3ac49cb3.eot 33.6 KiB
webpack-dev-server | media/webfonts/fa-regular-400-9efb8697.woff2 13.3 KiB
webpack-dev-server | media/webfonts/fa-regular-400-a57bcf76.woff 16.4 KiB
webpack-dev-server | media/webfonts/fa-regular-400-d2e53334.svg 141 KiB
webpack-dev-server | media/webfonts/fa-regular-400-ece54318.ttf 33.3 KiB
webpack-dev-server | media/webfonts/fa-solid-900-2aa6edf8.ttf 189 KiB
webpack-dev-server | media/webfonts/fa-solid-900-7a5de9b0.svg 829 KiB
webpack-dev-server | media/webfonts/fa-solid-900-7fb1cdd9.eot 190 KiB
webpack-dev-server | media/webfonts/fa-solid-900-93f28454.woff 96.7 KiB
webpack-dev-server | media/webfonts/fa-solid-900-f6121be5.woff2 74.3 KiB
webpack-dev-server |
webpack-dev-server | ERROR in ./app/javascript/web3/index.js 126:22-26
webpack-dev-server | "export 'default' (imported as 'Web3') was not found in 'web3'
webpack-dev-server | at HarmonyImportSpecifierDependency._getErrors (/app/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:109:11)
webpack-dev-server | at HarmonyImportSpecifierDependency.getErrors (/app/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:68:16)
webpack-dev-server | at Compilation.reportDependencyErrorsAndWarnings (/app/node_modules/webpack/lib/Compilation.js:1463:22)
webpack-dev-server | at /app/node_modules/webpack/lib/Compilation.js:1258:10
webpack-dev-server | at AsyncSeriesHook.eval [as callAsync] (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
webpack-dev-server | at AsyncSeriesHook.lazyCompileHook (/app/node_modules/tapable/lib/Hook.js:154:20)
webpack-dev-server | at Compilation.finish (/app/node_modules/webpack/lib/Compilation.js:1253:28)
webpack-dev-server | at /app/node_modules/webpack/lib/Compiler.js:672:17
webpack-dev-server | at _done (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
webpack-dev-server | at eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:32:22)
webpack-dev-server |
webpack-dev-server | ERROR in ./app/javascript/web3/index.js 130:22-26
webpack-dev-server | "export 'default' (imported as 'Web3') was not found in 'web3'
webpack-dev-server | at HarmonyImportSpecifierDependency._getErrors (/app/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:109:11)
webpack-dev-server | at HarmonyImportSpecifierDependency.getErrors (/app/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:68:16)
webpack-dev-server | at Compilation.reportDependencyErrorsAndWarnings (/app/node_modules/webpack/lib/Compilation.js:1463:22)
webpack-dev-server | at /app/node_modules/webpack/lib/Compilation.js:1258:10
webpack-dev-server | at AsyncSeriesHook.eval [as callAsync] (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
webpack-dev-server | at AsyncSeriesHook.lazyCompileHook (/app/node_modules/tapable/lib/Hook.js:154:20)
webpack-dev-server | at Compilation.finish (/app/node_modules/webpack/lib/Compilation.js:1253:28)
webpack-dev-server | at /app/node_modules/webpack/lib/Compiler.js:672:17
webpack-dev-server | at _done (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
webpack-dev-server | at eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:32:22)
webpack-dev-server |
webpack-dev-server | ERROR in ./app/javascript/web3/index.js 130:31-35
webpack-dev-server | "export 'default' (imported as 'Web3') was not found in 'web3'
webpack-dev-server | at HarmonyImportSpecifierDependency._getErrors (/app/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:109:11)
webpack-dev-server | at HarmonyImportSpecifierDependency.getErrors (/app/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js:68:16)
webpack-dev-server | at Compilation.reportDependencyErrorsAndWarnings (/app/node_modules/webpack/lib/Compilation.js:1463:22)
webpack-dev-server | at /app/node_modules/webpack/lib/Compilation.js:1258:10
webpack-dev-server | at AsyncSeriesHook.eval [as callAsync] (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
webpack-dev-server | at AsyncSeriesHook.lazyCompileHook (/app/node_modules/tapable/lib/Hook.js:154:20)
webpack-dev-server | at Compilation.finish (/app/node_modules/webpack/lib/Compilation.js:1253:28)
webpack-dev-server | at /app/node_modules/webpack/lib/Compiler.js:672:17
webpack-dev-server | at _done (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
webpack-dev-server | at eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:32:22)
webpack-dev-server | ℹ 「wdm」: Failed to compile.
Websearches have not unearthed any possible solutions, and I have not dug up any examples of using web3.js using Webpacker in Rails. Is it possible; any solutions or examples out there?
Thanks!
I think this is a naming conflict. You've named your own javascript file web3/index.js, which Webpack sees as web3; that conflicts with the node module you're trying to import by the same name. Try renaming your own javascript folder/file to something else. Related issue: https://github.com/webpack/webpack/issues/4817#issuecomment-316119100

Parse Command Outputting Horizontally

I have a script that parses a log file for the last 15 lines but it outputs the data in a horizontal line which I think interferes when I try to get an average of the numbers in the file.
Here's an example of the log file I'm parsing:
3/22/2016 9:11:21 AM 44.0
3/22/2016 9:11:22 AM 44.1
3/22/2016 9:11:23 AM 44.2
3/22/2016 9:11:24 AM 44.3
And here's my PowerShell command that parses the last 15 lines of the active log file.
$regexNUM = '\d+\.\d+'
$NUMLog = Get-ChildItem -Path 'C:\Users\Admin\Documents' |
Where-Object {$_.Name -match "LOGFILE"} |
Sort LastWriteTime | Select -Last 1
$NUMBERS = Get-Content -Path "C:\Users\Admin\Documents\$NumLog" -Tail 15 |
Select-String -Pattern $regexNum -AllMatches |
% { $_.Matches } | % { $_.Groups }
When I do a Write-Host $NUMBERS it outputs the data like this:
39.5 39.6 39.7 39.8 39.9 40.0 40.1 40.2 40.3 40.4 40.5 40.6 40.7 40.8 40.9
And here's how I'm trying to get the average of these 15 numbers:
$Average = $NUMBERS | Measure-Object -Average | Select Average
When I do Write-Host $Average it says:
Measure-Object : Input object "39.5" is not numeric.
At C:\Users\Admin\Documents\SampleTest.ps1:26 char:30
+ $Average = $NUMBERS | Measure-Object -Average | Select Average
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (39.5:Match) [Measure-Object], PSInvalidOperationException
+ FullyQualifiedErrorId : NonNumericInputObject,Microsoft.PowerShell.Commands.MeasureObjectCommand
I'm not sure why it would say the number 39.5 is not numeric but all I can assume is that it doesn't like it being horizontal with the spaces maybe. It throws one of those errors for each of the 15 numbers too.
Problem:
The problem in your code is that you are actually feeding objects of type System.Text.RegularExpressions.Match to the Measure-Object cmdlet, and not numbers.
The Write-Host command is automatically converting the Match object to text when it needs to output it to the console, and that makes you think it looks like numbers.
Solution:
To fix that, change the following line to get values inside the Match objects:
$NUMBERS = Get-Content -Path "C:\Users\Admin\Documents\$NumLog" -Tail 15 |
Select-String -Pattern $regexNum -AllMatches |
% { $_.Matches } | % { $_.Value }
Advice:
To fix problems like this yourself, you can use the the Get-Member cmdlet to check what is the type returned.
In your case, you can send the output of the second Get-Content cmdlet to Get-Member, instead of saving it to a variable:
Get-Content -Path "C:\Users\Admin\Documents\$NumLog" -Tail 15 |
Select-String -Pattern $regexNum -AllMatches |
% { $_.Matches } | % { $_.Groups } | Get-Member

Why this parameter '+profile "*"' get convert killed?

If I run this command,
convert -limit memory 2071963648 -quality 100 -alpha off -density 165% -scene 1 infile.jpg outfile.png
The conversion runs without any issue.
However if I add +profile "*",
convert +profile "*" -limit memory 2071963648 -quality 100 -alpha off -density 165% -scene 1 infile.jpg outfile.png
The process is killed.
Here is output from dmesg
[ 1403.401440] [ pid ] uid tgid total_vm rss nr_ptes swapents oom_score_adj name
[ 1403.401444] [ 474] 0 474 4869 49 13 0 0 upstart-udev-br
[ 1403.401446] [ 480] 0 480 12460 207 27 0 -1000 systemd-udevd
[ 1403.401448] [ 659] 0 659 3815 55 13 0 0 upstart-socket-
[ 1403.401449] [ 671] 0 671 2556 572 8 0 0 dhclient
[ 1403.401451] [ 852] 102 852 9806 94 23 0 0 dbus-daemon
[ 1403.401453] [ 860] 101 860 65019 147 29 0 0 rsyslogd
[ 1403.401454] [ 884] 0 884 10863 85 27 0 0 systemd-logind
[ 1403.401456] [ 888] 0 888 3819 64 11 0 0 upstart-file-br
[ 1403.401463] [ 967] 0 967 3635 41 12 0 0 getty
[ 1403.401464] [ 970] 0 970 3635 42 12 0 0 getty
[ 1403.401466] [ 974] 0 974 3635 40 12 0 0 getty
[ 1403.401467] [ 975] 0 975 3635 40 12 0 0 getty
[ 1403.401468] [ 977] 0 977 3635 41 12 0 0 getty
[ 1403.401470] [ 1047] 0 1047 15341 169 33 0 -1000 sshd
[ 1403.401472] [ 1052] 0 1052 5914 58 17 0 0 cron
[ 1403.401473] [ 1057] 0 1057 4785 40 13 0 0 atd
[ 1403.401475] [ 1089] 0 1089 1092 36 8 0 0 acpid
[ 1403.401476] [ 1099] 0 1099 4797 63 15 0 0 irqbalance
[ 1403.401478] [ 1224] 0 1224 6336 78 16 0 0 master
[ 1403.401479] [ 1230] 106 1230 6852 73 18 0 0 pickup
[ 1403.401481] [ 1231] 106 1231 6893 81 19 0 0 qmgr
[ 1403.401482] [ 1281] 999 1281 278175 5269 82 0 0 sensu-client
[ 1403.401484] [ 1397] 0 1397 3635 42 11 0 0 getty
[ 1403.401485] [ 1398] 0 1398 3197 37 11 0 0 getty
[ 1403.401487] [ 1515] 107 1515 7862 150 19 0 0 ntpd
[ 1403.401488] [ 1929] 0 1929 26408 247 55 0 0 sshd
[ 1403.401490] [ 1982] 1000 1982 26442 256 53 0 0 sshd
[ 1403.401491] [ 1983] 1000 1983 5580 761 16 0 0 bash
[ 1403.401493] [ 2488] 1000 2488 8685 1607 22 0 0 pynt
[ 1403.401494] [ 2490] 1000 2490 8685 1607 21 0 0 pynt
[ 1403.401495] [ 2491] 1000 2491 1111 24 7 0 0 sh
[ 1403.401497] [ 2492] 1000 2492 1111 25 7 0 0 sh
[ 1403.401498] [ 2493] 1000 2493 15638 3221 36 0 0 python
[ 1403.401500] [ 2494] 1000 2494 15939 3535 36 0 0 python
[ 1403.401501] [ 2924] 1000 2924 975967 954941 1894 0 0 convert
[ 1403.401503] Out of memory: Kill process 2924 (convert) score 945 or sacrifice child
[ 1403.406111] Killed process 2924 (convert) total-vm:3903868kB, anon-rss:3819760kB, file-rss:4kB
I am using this version of ImageMagick
$ convert -version
Version: ImageMagick 6.8.9-7 Q16 x86_64 2014-12-30 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: jng jpeg png x xml zlib
on ubuntu 14.04.1
I don't know why +profile would cause ImageMagick to crash, but as an alternative you might like to try -strip like this.
convert image.jpg -strip output.jpg
It strips the image of all profiles and comments.

Failed to deserialize exception response from stream - Grails ElasticSearch

I have a simple Grails app, which I am trying to set upo to use ElasticSearch.
I have a single-node ElasticSearch instance running on EC2, which is running happily enough. (For reference, I just followed the steps here: http://www.elasticsearch.org/tutorials/elasticsearch-on-ec2/), but using 0.90.7 and the cloud-aws plugin version 1.15.0)
I am using the Grails ElasticSearch GORM plugin (http://grails.org/plugin/elasticsearch-gorm) (Master branch) and i'm connecting to ES using the transport client mode (elasticSearch.client.mode = 'transport')
Here's where it gets really odd...
The first time I boot up my app, it will happily index my Domain data on ES, I can query, etc, no problems.
If I then restart my grails app, it won't launch at all. I get
Message: Error creating bean with name 'searchableClassMappingConfigurator': Invocation of init method failed; nested exception is org.elasticsearch.transport.TransportSerializationException: Failed to deserialize exception response from stream
Line | Method
->> 262 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run in java.lang.Thread
Caused by TransportSerializationException: Failed to deserialize exception response from stream
->> 169 | handlerResponseError in org.elasticsearch.transport.netty.MessageChannelHandler
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 123 | messageReceived in ''
| 70 | handleUpstream in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
| 564 | sendUpstream in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
| 791 | sendUpstream in org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext
| 296 | fireMessageReceived in org.elasticsearch.common.netty.channel.Channels
| 462 | unfoldAndFireMessageReceived in org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder
| 443 | callDecode in ''
| 310 | messageReceived in ''
| 70 | handleUpstream in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
| 564 | sendUpstream in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
| 559 | sendUpstream in ''
| 268 | fireMessageReceived in org.elasticsearch.common.netty.channel.Channels
| 255 | fireMessageReceived in ''
| 88 | read . . in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
| 108 | process in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
| 318 | run . . . in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector
| 89 | run in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
| 178 | run . . . in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
| 108 | run in org.elasticsearch.common.netty.util.ThreadRenamingRunnable
| 42 | run . . . in org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run in java.lang.Thread
Caused by StreamCorruptedException: unexpected end of block data
->> 1370 | readObject0 in java.io.ObjectInputStream
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1989 | defaultReadFields in ''
| 499 | defaultReadObject in ''
| 914 | readObject in java.lang.Throwable
| 1017 | invokeReadObject in java.io.ObjectStreamClass
| 1891 | readSerialData in java.io.ObjectInputStream
| 1796 | readOrdinaryObject in ''
| 1348 | readObject0 in ''
| 1989 | defaultReadFields in ''
| 499 | defaultReadObject in ''
| 914 | readObject in java.lang.Throwable
| 1017 | invokeReadObject in java.io.ObjectStreamClass
| 1891 | readSerialData in java.io.ObjectInputStream
| 1796 | readOrdinaryObject in ''
| 1348 | readObject0 in ''
| 370 | readObject in ''
| 167 | handlerResponseError in org.elasticsearch.transport.netty.MessageChannelHandler
| 123 | messageReceived in ''
| 70 | handleUpstream in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
| 564 | sendUpstream in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
| 791 | sendUpstream in org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext
| 296 | fireMessageReceived in org.elasticsearch.common.netty.channel.Channels
| 462 | unfoldAndFireMessageReceived in org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder
| 443 | callDecode in ''
| 310 | messageReceived in ''
| 70 | handleUpstream in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
| 564 | sendUpstream in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
| 559 | sendUpstream in ''
| 268 | fireMessageReceived in org.elasticsearch.common.netty.channel.Channels
| 255 | fireMessageReceived in ''
| 88 | read . . in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
| 108 | process in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
| 318 | run . . . in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector
| 89 | run in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
| 178 | run . . . in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
| 108 | run in org.elasticsearch.common.netty.util.ThreadRenamingRunnable
| 42 | run . . . in org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run in java.lang.Thread
This happens until I change the elasticSearch host details - ie, I can't boot my ap at all, with the original host details, ever again.
Both the ES node and my Grails app are both using elasticSearch 0.90.7, my config for the ES plugin looks like so:#
elasticSearch.client.mode = 'transport'
elasticSearch.client.hosts = [[host:'<my EC2 DNS>', port:9300]]
elasticSearch.datastoreImpl = 'mongoDatastore'
elasticSearch.client.transport.sniff = true
The only domain object I am marking as 'searchable' is mapped with mongoDB, which looks like so:
class CompletedApplicationFormSearchEntry {
static searchable = true
Long formId
Long jobId
Long employerId
Long jobseekerId
Date applicationDate
static mapWith = "mongo"
static constraints = {
}
}
If I remove the searchable attribute from the domain class, then relaunch the app, it launches fine, so I assume that there's something going on in the bootstrapping process when the domain object is detected as being searchable, but of course, it only causes an issue when the app's been restarted.
There are a handful of threads kicking about where people are seeing similar issue,s where they have nodes running different ES versions, different JVM version,s etc. But in this case, I only have one node!
I am absolutely tearing my hair out over this - I just can't work out what on earth's going wrong. I've tried different plugin versions, elasticsearch versions, 32-bit EC2 instance, 64bit EC2 instance - no luck!
Not with grails es plugin, but I fixed similar issue by fixing the jvm versions in ide ( used by the es client) to be the same as es master running on different jvm version.
STEP 0 : Make sure api and actual es version are identical.
STEP 1 : check jvm versions used by the es nodes
In following case, I had two different jvm versions, as pointed by "jvm" json key of both es nodes.
$ curl -XGET "http://localhost:9200/_nodes?jvm=true&pretty=true"
{
"cluster_name" : "elasticsearch",
"nodes" : {
"A6PDUvlWSN-zN2GKRxrSHA" : {
"name" : "Madeline Joyce",
"transport_address" : "inet[/192.168.1.4:9301]",
"host" : "prayagupd",
"ip" : "127.0.1.1",
"version" : "1.3.2",
"build" : "dee175d",
"http_address" : "inet[/192.168.1.4:9201]",
"settings" : {
"path" : {
"logs" : "/usr/local/elasticsearch-1.3.2/logs",
"home" : "/usr/local/elasticsearch-1.3.2"
},
"cluster" : {
"name" : "elasticsearch"
},
"http" : {
"port" : "9201"
},
"transport" : {
"tcp" : {
"port" : "9301"
}
},
"foreground" : "yes",
"name" : "Madeline Joyce"
},
"os" : {
"refresh_interval_in_millis" : 1000,
"available_processors" : 4,
"cpu" : {
"vendor" : "Intel",
"model" : "Core(TM) i5 CPU M 480 # 2.67GHz",
"mhz" : 2667,
"total_cores" : 4,
"total_sockets" : 4,
"cores_per_socket" : 16,
"cache_size_in_bytes" : 3072
},
"mem" : {
"total_in_bytes" : 3803283456
},
"swap" : {
"total_in_bytes" : 5998899200
}
},
"process" : {
"refresh_interval_in_millis" : 1000,
"id" : 9036,
"max_file_descriptors" : 4096,
"mlockall" : false
},
"jvm" : {
"pid" : 9036,
"version" : "1.7.0_65",
"vm_name" : "Java HotSpot(TM) 64-Bit Server VM",
"vm_version" : "24.65-b04",
"vm_vendor" : "Oracle Corporation",
"start_time_in_millis" : 1421578674811,
"mem" : {
"heap_init_in_bytes" : 268435456,
"heap_max_in_bytes" : 1038876672,
"non_heap_init_in_bytes" : 24313856,
"non_heap_max_in_bytes" : 136314880,
"direct_max_in_bytes" : 1038876672
},
"gc_collectors" : [ "ParNew", "ConcurrentMarkSweep" ],
"memory_pools" : [ "Code Cache", "Par Eden Space", "Par Survivor Space", "CMS Old Gen", "CMS Perm Gen" ]
},
"thread_pool" : {
"generic" : {
"type" : "cached",
"keep_alive" : "30s",
"queue_size" : -1
},
"index" : {
"type" : "fixed",
"min" : 4,
"max" : 4,
"queue_size" : "200"
},
"snapshot_data" : {
"type" : "scaling",
"min" : 1,
"max" : 5,
"keep_alive" : "5m",
"queue_size" : -1
},
"bench" : {
"type" : "scaling",
"min" : 1,
"max" : 2,
"keep_alive" : "5m",
"queue_size" : -1
},
"get" : {
"type" : "fixed",
"min" : 4,
"max" : 4,
"queue_size" : "1k"
},
"snapshot" : {
"type" : "scaling",
"min" : 1,
"max" : 2,
"keep_alive" : "5m",
"queue_size" : -1
},
"merge" : {
"type" : "scaling",
"min" : 1,
"max" : 2,
"keep_alive" : "5m",
"queue_size" : -1
},
"suggest" : {
"type" : "fixed",
"min" : 4,
"max" : 4,
"queue_size" : "1k"
},
"bulk" : {
"type" : "fixed",
"min" : 4,
"max" : 4,
"queue_size" : "50"
},
"optimize" : {
"type" : "fixed",
"min" : 1,
"max" : 1,
"queue_size" : -1
},
"warmer" : {
"type" : "scaling",
"min" : 1,
"max" : 2,
"keep_alive" : "5m",
"queue_size" : -1
},
"flush" : {
"type" : "scaling",
"min" : 1,
"max" : 2,
"keep_alive" : "5m",
"queue_size" : -1
},
"search" : {
"type" : "fixed",
"min" : 12,
"max" : 12,
"queue_size" : "1k"
},
"percolate" : {
"type" : "fixed",
"min" : 4,
"max" : 4,
"queue_size" : "1k"
},
"management" : {
"type" : "scaling",
"min" : 1,
"max" : 5,
"keep_alive" : "5m",
"queue_size" : -1
},
"refresh" : {
"type" : "scaling",
"min" : 1,
"max" : 2,
"keep_alive" : "5m",
"queue_size" : -1
}
},
"network" : {
"refresh_interval_in_millis" : 5000,
"primary_interface" : {
"address" : "192.168.1.4",
"name" : "eth0",
"mac_address" : "20:6A:8A:2A:24:E6"
}
},
"transport" : {
"bound_address" : "inet[/0:0:0:0:0:0:0:0%0:9301]",
"publish_address" : "inet[/192.168.1.4:9301]"
},
"http" : {
"bound_address" : "inet[/0:0:0:0:0:0:0:0%0:9201]",
"publish_address" : "inet[/192.168.1.4:9201]",
"max_content_length_in_bytes" : 104857600
},
"plugins" : [ ]
},
"TWNkkYYZSWe8NnrOPU57mQ" : {
"name" : "Scarlet Spider",
"transport_address" : "inet[/192.168.1.4:9300]",
"host" : "prayagupd",
"ip" : "127.0.1.1",
"version" : "1.3.2",
"build" : "dee175d",
"http_address" : "inet[/192.168.1.4:9200]",
"attributes" : {
"client" : "true",
"data" : "false"
},
"settings" : {
"path" : {
"data" : "/var/lib/elasticsearch",
"work" : "/tmp/elasticsearch",
"conf" : "/etc/elasticsearch",
"logs" : "/var/log/elasticsearch"
},
"cluster" : {
"name" : "elasticsearch"
},
"node" : {
"client" : "true"
},
"name" : "Scarlet Spider"
},
"os" : {
"refresh_interval_in_millis" : 1000,
"available_processors" : 4
},
"process" : {
"refresh_interval_in_millis" : 1000,
"id" : 11028,
"max_file_descriptors" : 4096,
"mlockall" : false
},
"jvm" : {
"pid" : 11028,
"version" : "1.7.0_05",
"vm_name" : "Java HotSpot(TM) 64-Bit Server VM",
"vm_version" : "23.1-b03",
"vm_vendor" : "Oracle Corporation",
"start_time_in_millis" : 1421580829189,
"mem" : {
"heap_init_in_bytes" : 59426304,
"heap_max_in_bytes" : 846331904,
"non_heap_init_in_bytes" : 24313856,
"non_heap_max_in_bytes" : 136314880,
"direct_max_in_bytes" : 846331904
},
"gc_collectors" : [ "PS Scavenge", "PS MarkSweep" ],
"memory_pools" : [ "Code Cache", "PS Eden Space", "PS Survivor Space", "PS Old Gen", "PS Perm Gen" ]
},
"thread_pool" : {
"generic" : {
"type" : "cached",
"keep_alive" : "30s",
"queue_size" : -1
},
"index" : {
"type" : "fixed",
"min" : 4,
"max" : 4,
"queue_size" : "200"
},
"snapshot_data" : {
"type" : "scaling",
"min" : 1,
"max" : 5,
"keep_alive" : "5m",
"queue_size" : -1
},
"bench" : {
"type" : "scaling",
"min" : 1,
"max" : 2,
"keep_alive" : "5m",
"queue_size" : -1
},
"get" : {
"type" : "fixed",
"min" : 4,
"max" : 4,
"queue_size" : "1k"
},
"snapshot" : {
"type" : "scaling",
"min" : 1,
"max" : 2,
"keep_alive" : "5m",
"queue_size" : -1
},
"merge" : {
"type" : "scaling",
"min" : 1,
"max" : 2,
"keep_alive" : "5m",
"queue_size" : -1
},
"suggest" : {
"type" : "fixed",
"min" : 4,
"max" : 4,
"queue_size" : "1k"
},
"bulk" : {
"type" : "fixed",
"min" : 4,
"max" : 4,
"queue_size" : "50"
},
"optimize" : {
"type" : "fixed",
"min" : 1,
"max" : 1,
"queue_size" : -1
},
"warmer" : {
"type" : "scaling",
"min" : 1,
"max" : 2,
"keep_alive" : "5m",
"queue_size" : -1
},
"flush" : {
"type" : "scaling",
"min" : 1,
"max" : 2,
"keep_alive" : "5m",
"queue_size" : -1
},
"search" : {
"type" : "fixed",
"min" : 12,
"max" : 12,
"queue_size" : "1k"
},
"percolate" : {
"type" : "fixed",
"min" : 4,
"max" : 4,
"queue_size" : "1k"
},
"management" : {
"type" : "scaling",
"min" : 1,
"max" : 5,
"keep_alive" : "5m",
"queue_size" : -1
},
"refresh" : {
"type" : "scaling",
"min" : 1,
"max" : 2,
"keep_alive" : "5m",
"queue_size" : -1
}
},
"network" : {
"refresh_interval_in_millis" : 5000
},
"transport" : {
"bound_address" : "inet[/0:0:0:0:0:0:0:0:9300]",
"publish_address" : "inet[/192.168.1.4:9300]"
},
"http" : {
"bound_address" : "inet[/0:0:0:0:0:0:0:0:9200]",
"publish_address" : "inet[/192.168.1.4:9200]",
"max_content_length_in_bytes" : 104857600
},
"plugins" : [ ]
}
}
}
STEP 2: update jvm version in ide (following shows for intellij ide)
Update to required jvm version, and add to project,
STEP 3 : Run both es nodes, the problem of TransportSerializationException should get fixed
$ curl -XGET "http://localhost:9200/_nodes?jvm=true&pretty=true"
{
"cluster_name": "elasticsearch",
"nodes": {
"GeRZFRiDSje8zLM_m90WRw": {
"name" : "Dougboy",
"jvm": {
"pid": 15223,
"version": "1.7.0_65",
"vm_name": "Java HotSpot(TM) 64-Bit Server VM",
"vm_version": "24.65-b04",
"vm_vendor": "Oracle Corporation",
"start_time_in_millis": 1421586819876,
"mem": {
"heap_init_in_bytes": 59426304,
"heap_max_in_bytes": 846200832,
"non_heap_init_in_bytes": 24576000,
"non_heap_max_in_bytes": 136314880,
"direct_max_in_bytes": 846200832
}
}
},
"A6PDUvlWSN-zN2GKRxrSHA": {
"name": "Madeline Joyce",
"jvm": {
"pid": 9036,
"version": "1.7.0_65",
"vm_name": "Java HotSpot(TM) 64-Bit Server VM",
"vm_version": "24.65-b04",
"vm_vendor": "Oracle Corporation",
"start_time_in_millis": 1421578674811,
"mem": {
"heap_init_in_bytes": 268435456,
"heap_max_in_bytes": 1038876672,
"non_heap_init_in_bytes": 24313856,
"non_heap_max_in_bytes": 136314880,
"direct_max_in_bytes": 1038876672
}
}
}
}
}
Reference
Java Client TransportSerializationException #3835, Oct 6, 2013
Looks like it was an issue with the plugin with Elasticsearch 0.90.7 throwing an exception which wasn't caught by the plugin.
Pull request here: https://github.com/mstein/elasticsearch-grails-plugin/pull/74 has a fix and includes ES 0.90.7

Resources