From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29773 invoked by alias); 14 Oct 2014 03:03:11 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19252 Received: (qmail 10750 invoked from network); 14 Oct 2014 03:02:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,PLING_QUERY, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 From: Bart Schaefer Message-id: <141013200256.ZM6956@torch.brasslantern.com> Date: Mon, 13 Oct 2014 20:02:56 -0700 In-reply-to: <543C0B98.2080504@gmail.com> Comments: In reply to Vasiliy Ivanov "Re: Doing NMEA command sequences with zsh ... ??!!" (Oct 13, 11:27pm) References: <20141013155806.GA3825@solfire> <543C0B98.2080504@gmail.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Doing NMEA command sequences with zsh ... ??!! MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Oct 13, 11:27pm, Vasiliy Ivanov wrote: } Subject: Re: Doing NMEA command sequences with zsh ... ??!! } } > An NMEA command sequence consist of } > $<*> } > } > 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