From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Doing NMEA command sequences with zsh ... ??!!
Date: Mon, 13 Oct 2014 20:02:56 -0700 [thread overview]
Message-ID: <141013200256.ZM6956@torch.brasslantern.com> (raw)
In-Reply-To: <543C0B98.2080504@gmail.com>
On Oct 13, 11:27pm, Vasiliy Ivanov wrote:
} Subject: Re: Doing NMEA command sequences with zsh ... ??!!
}
} > An NMEA command sequence consist of
} > $<commandname><parameter,nextparameter,....><*><checksum>
} >
} > The checksum is the binary XOR of all characters between '$' and '*'.
} > This checksum is given a an hexadecimal number.
}
} Not digging deep into NMEA stuff, only some related hints:
}
} % integer a b; a=16#e7; b=16#3c; print $(([#16]a^b));
} 16#DB
}
} % c='abcABC'; for i in ${(s..)c}; do print $((#i)); done
} 97
} 98
} 99
} 65
} 66
} 67
Zsh does support bitwise math ops, so
--- 8< --- snip --- 8< ---
print_nmea () {
setopt localoptions C_BASES
integer -i 16 checksum
local i
local commandname=$1
shift
local parameters=${(j:,:)*}
local NMEA="$commandname$parameters"
for i in ${(s..)NMEA}; do
(( checksum ^= #i ))
done
print \$$NMEA\*$checksum
}
--- 8< --- snip --- 8< ---
--
Barton E. Schaefer
prev parent reply other threads:[~2014-10-14 3:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-13 15:58 meino.cramer
2014-10-13 17:27 ` Vasiliy Ivanov
2014-10-14 3:02 ` Bart Schaefer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=141013200256.ZM6956@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).