How to transfer some XAS to a Dapp with asch-cli - asch-development

I've tried:
asch-cli -H 127.0.0.1 -P 4096 dapptransaction --secret "acquire paper fun spice celery design able shrimp lunch angry alter gather" --dapp 559ddee66bacb008f1a5eb2692ef18ba9b0d9da923989da4070c0fd33d0d3352 --args "{currency:'XAS',amount:5000000000}" --fee 10000000

The comple documentation of asch-cli can be found at https://github.com/AschPlatform/asch-docs/blob/master/cli_usage/en.md. You should try to use to replace dapptransaction with deposit.
So try something like that shown below:
asch-cli -H 127.0.0.1 -P 4096 deposit --secret "" --dapp "" --currency "XAS" --amount 5000

Related

efi shell command and register R/W

I got a basic question of efi mm command.
I need to control a controller (MAC) inside a SOC, and let it generate MDIO traffic to external PHY chip, to read its ID.
The instruction told me to do the following under efi shell
Shell> mm xxxxxxx yyyyyyy -w 4 -MEM -n
Shell> mm xxxxxxx -w 4 -MEM -n
I'm wondering what's the mm command do?
Looks like it write to xxxxxx register the yyyyyy data, and then "mm" this register again?
Not sure why.
Can anyone help me on this?
The mm command is explained in the UEFI Shell Specification:
mm address [value] [-w 1|2|4|8] [-MEM | -PMEM | -MMIO | -IO | -PCI | -PCIE] [-
n]
The description states "If value is specified, which should be typed in hex format, this command will write this value to specified address. Otherwise when this command is executed, the current contents of address are displayed.".
So your first command writes the 32-bit value yyyyyyy to address xxxxxxx, and the second command reads a 32-bit value from address xxxxxxx - presumably to verify that the write took effect.
Sample startup.nsh
#Sample startup.nsh
#echo -off
# Clear screen
cls
# Print date and time
date
time
# Set special register of the CPU (Intel Denverton C3758R)
# EFI Shell style is "mm fe000018 29C0202C -w 4 -MEM -n"
# (more detail usage, Use "help mm")
# but not implement in startup.nsh with error "Invalid data width"
# No need option "-n" for Non-interactive write
mm fe000018 4 :29C0002C
# Non-interactive read
mm fe000018 4 -n
mm e00fa0a4 4 -n
# System shutdown
reset -s

use gpsd or cgps to return latitude and longitude then quit

I would like a dead-simple way to query my gps location from a usb dongle from the unix command line.
Right now, I know I've got a functioning software and hardware system, as evidenced by the success of the cgps command in showing me my position. I'd now like to be able to make short requests for my gps location (lat,long in decimals) from the command line. my usb serial's path is /dev/ttyUSB0 and I'm using a Global Sat dongle that outputs generic NMEA sentences
How might I accomplish this?
Thanks
telnet 127.0.0.1 2947
?WATCH={"enable":true}
?POLL;
gives you your answer, but you still need to separate the wheat from the chaff. It also assumes the gps is not coming in from a cold start.
A short script could be called, e.g.;
#!/bin/bash
exec 2>/dev/null
# get positions
gpstmp=/tmp/gps.data
gpspipe -w -n 40 >$gpstmp"1"&
ppid=$!
sleep 10
kill -9 $ppid
cat $gpstmp"1"|grep -om1 "[-]\?[[:digit:]]\{1,3\}\.[[:digit:]]\{9\}" >$gpstmp
size=$(stat -c%s $gpstmp)
if [ $size -gt 10 ]; then
cat $gpstmp|sed -n -e 1p >/tmp/gps.lat
cat $gpstmp|sed -n -e 2p >/tmp/gps.lon
fi
rm $gpstmp $gpstmp"1"
This will cause 40 sentences to be output and then grep lat/lon to temporary files and then clean up.
Or, from GPS3 github repository place the alpha gps3.py in the same directory as, and execute, the following Python2.7-3.4 script.
from time import sleep
import gps3
the_connection = gps3.GPSDSocket()
the_fix = gps3.DataStream()
try:
for new_data in the_connection:
if new_data:
the_fix.refresh(new_data)
if not isinstance(the_fix.TPV['lat'], str): # check for valid data
speed = the_fix.TPV['speed']
latitude = the_fix.TPV['lat']
longitude = the_fix.TPV['lon']
altitude = the_fix.TPV['alt']
print('Latitude:', latitude, 'Longitude:', longitude)
sleep(1)
except KeyboardInterrupt:
the_connection.close()
print("\nTerminated by user\nGood Bye.\n")
If you want it to close after one iteration also import sys and then replace sleep(1) with sys.exit()
much easier solution:
$ gpspipe -w -n 10 | grep -m 1 lon
{"class":"TPV","device":"tcp://localhost:4352","mode":2,"lat":11.1111110000,"lon":22.222222222}
source
You can use my script : gps.sh return "x,y"
#!/bin/bash
x=$(gpspipe -w -n 10 |grep lon|tail -n1|cut -d":" -f9|cut -d"," -f1)
y=$(gpspipe -w -n 10 |grep lon|tail -n1|cut -d":" -f10|cut -d"," -f1)
echo "$x,$y"
sh gps.sh
43.xx4092000,6.xx1269167
Putting a few of the bits of different answers together with a bit more jq work, I like this version:
$ gpspipe -w -n 10 | grep -m 1 TPV | jq -r '[.lat, .lon] | #csv'
40.xxxxxx054,-79.yyyyyy367
Explanation:
(1) use grep -m 1 after invoking gpspipe, as used by #eadmaster's answer, because the grep will exit as soon as the first match is found. This gets you results faster instead of having to wait for 10 lines (or using two invocations of gpspipe).
(2) use jq to extract both fields simultaneously; the #csv formatter is more readable. Note the use of jq -r (raw output), so that the output is not put in quotes. Otherwise the output would be "40.xxxx,-79.xxxx" - which might be fine or better for some applications.
(3) Search for the TPV field by name for clarity. This is the "time, position, velocity" record, which is the one we want for extracting the current lat & lon. Just searching for "lat" or "lon" risks getting confused by the GST object that some GPSes may supply, and in that object, 'lat' and 'lon' are the standard deviation of the position error, not the position itself.
Improving on eadmaster's answer here is a more elegant solution:
gpspipe -w -n 10 | jq -r '.lon' | grep "[[:digit:]]" | tail -1
Explanation:
Ask from gpsd 10 times the data
Parse the received JSONs using jq
We want only numeric values, so filter using grep
We want the last received value, so use tail for that
Example:
$ gpspipe -w -n 10 | jq -r '.lon' | grep "[[:digit:]]" | tail -1
28.853181286

Create a torrent with Transmission doesn't work

I try to create my own torrent with transmission in command line.
I follow a basic tutorial but I missed something: https://forum.transmissionbt.com/viewtopic.php?f=8&p=55854
transmission-create --comment "my comment" --tracker "udp://tracker.openb ittorrent.com:80/announce" --outfile test.torrent MyFile.txt
Creating torrent "test.torrent" ..... done!
And
transmission-show test.torrent
Name: MyFile.txt
File: test.torrent
GENERAL
Name: MyFile.txt
Hash: 67bd20d96046a0a80753fc6f0c93006077f99d7d
Created by: Transmission/2.52 (13304)
Created on: Sun Aug 3 12:31:29 2014
Comment: my comment
Piece Count: 1574
Piece Size: 32.00 KiB
Total Size: 51.57 MB
Privacy: Public torrent
TRACKERS
Tier #1
udp://tracker.openbittorrent.com:80/announce
FILES
MyFile.txt
Ok now, when i upload the torrent on my computer, i use utorrent. He blocks to :
Connection to pairs 0%
Basically i have this :
So i'm sure i have doing something wrong, or forgot something but i can't find what...

Error when running a unix 'at' job

The code is:
at -k $wval <<ENDMARKER
while [[ -s Usr_List ]]; do
for i in $(cat Usr_List); do
if finger -m | grep $i; then
echo "$i is online" | elm $mval
sed "/$i/d" <Usr_List >tmplist
mv tmplist Usr_List
fi
done
done
ENDMARKER
Looking at the actual at job, it is
while [[ -s Usr_List ]]; do
for i in jim
joe
tim; do
if finger -m |grep ; then
echo " is online" | elm jack
sed "//d" <Usr_List >tmplist
mv tmplist Usr_List
fi
done
done
jim joe and tim are the names on the list Usr_List
It seems like the cat Usr_List and the $i are the problem but I am not sure how to fix this.
Thanks
EDIT:
The at job sends an email saying that jim was unexpected.
Check man at, in particular the part about ".... executed at a later time, using /bin/sh.". The script you are showing is valid bash, but depending on what /bin/sh is on your system, may not be valid syntax.
What's Happening
The problem is that the lines in your here-doc are being expanded when you input the at command. That means that the shell expands $(cat Usr_List) into:
jim
joe
tim
And it expands $i into the empty string, because it is not yet defined.
What You Want to Happen
You really want those variables to be expanded when the at command fires, not when you're telling the at command what to do.
How to fix it
In order to keep the shell from expanding variables in a here-doc, you can simply quote your delimiter at the beginning. So, change your first line:
at -k $wval <<ENDMARKER
to
at -k $wval <<"ENDMARKER"
and it will work great.
Incidentally,
I'm curious, as my at command doesn't have a -k option--what is that supposed to do?

How to use the S-output-modifier with Unix/Linux command ps?

The command
ps -o time -p 21361
works; however what I need is the running time of the process including all
the children. For example, if 21361 is a bash script, which calls other scripts,
then I want the total running time, including the running time of all children.
Now the ps documentation lists the "OUTPUT MODIFIER":
S
Sum up some information, such as CPU usage, from dead child processes into their parent. This is useful for examining a system where a parent process repeatedly forks off short-lived children to do work.
Sounds just right. Unfortunately, there is no specification of the ps-syntax, so
I have no clue where to place the "S"! For hours now I tried many combinations, but
either I get syntax errors, or "S" makes nothing. And on the Internet you find only
very basic information about ps (and always the same), specifically the "S" modifier
I couldn't find mentioned anywhere, and also nobody ever explains the syntax of ps.
I am not sure, but it might be that ps is somewhat buggy in this respect. Try this here:
$ ps p 12104 k time
PID TTY STAT TIME COMMAND
12104 ? Ss 16:17 /usr/sbin/apache2 -k start
$ ps p 12104 k time S
PID TTY STAT TIME COMMAND
12104 ? Ss 143:16 /usr/sbin/apache2 -k start
This is using the BSD options for ps. It works on my machine, however you get an extra header row and extra columns. I would cut them away using tr and cut:
$ ps p 12104 k time S | tail -n 1 | tr -s '[:space:]' | cut -d ' ' -f 4
143:39
$ ps p 12104 k time | tail -n 1 | tr -s '[:space:]' | cut -d ' ' -f 4
16:17
On MacOS X (10.7, Lion) the manual page says:
-S Change the way the process time is calculated by summing all exited children to their parent process.
So, I was able to get output using:
$ ps -S -o time,etime,pid -p 305
TIME ELAPSED PID
0:00.12 01-18:31:07 305
$
However, that output was not really any different from when the '-S' option was omitted.
I tried:
$ ps -S -o time,etime,pid -p 305
TIME ELAPSED PID
0:00.14 01-18:43:59 305
$ time dd if=/dev/zero of=/dev/null bs=1m count=100k
102400+0 records in
102400+0 records out
107374182400 bytes transferred in 15.374440 secs (6983941055 bytes/sec)
real 0m15.379s
user 0m0.056s
sys 0m15.034s
$ ps -S -o time,etime,pid -p 305
TIME ELAPSED PID
0:00.14 01-18:44:15 305
$
As you can see, the 15 seconds of system time spent copying /dev/zero to /dev/null did not get included in the summary.
At this stage, the only way of working out what the '-S' option does, if anything, is to look at the source. You could look for sumrusage in the FreeBSD version, for example, at FreeBSD.

Resources