* Doing NMEA command sequences with zsh ... ??!!
@ 2014-10-13 15:58 meino.cramer
2014-10-13 17:27 ` Vasiliy Ivanov
0 siblings, 1 reply; 3+ messages in thread
From: meino.cramer @ 2014-10-13 15:58 UTC (permalink / raw)
To: zsh-users
Hi,
To my embedded system (which runs zsh on Gentoo Linux ;) ) I have
atteched an GPS receiver chip.
This chip spits out NMEA sentences to an UART and is capable of
receiving NMEA command seqyences.
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.
Since it is an embedded system, I would prefer to calculate this
checksum with zsh only since it already runs if I am logged in.
Is that possible in any way?
Thank you very much in advance for any help!
Best regards,
mcc
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Doing NMEA command sequences with zsh ... ??!!
2014-10-13 15:58 Doing NMEA command sequences with zsh ... ??!! meino.cramer
@ 2014-10-13 17:27 ` Vasiliy Ivanov
2014-10-14 3:02 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: Vasiliy Ivanov @ 2014-10-13 17:27 UTC (permalink / raw)
To: meino.cramer; +Cc: zsh-users
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 13.10.2014 21:58, meino.cramer@gmx.de wrote:
> Hi,
>
> To my embedded system (which runs zsh on Gentoo Linux ;) ) I have atteched an GPS receiver
> chip. This chip spits out NMEA sentences to an UART and is capable of receiving NMEA command
> seqyences.
>
> 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.
>
> Since it is an embedded system, I would prefer to calculate this checksum with zsh only since
> it already runs if I am logged in.
>
> Is that possible in any way?
>
> Thank you very much in advance for any help! Best regards, mcc
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
- --
Regards,
Vasiliy Ivanov <beelzebubbie.logs@gmail.com>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJUPAuYAAoJEAnDj7eK12hqw4kH/01EFxLtISDFEdWXL1yP0D7v
tUOi0WZGWhAqPSJ+q+cgpXXnUePGQsQ/phNjikex/S2GyG2MyyWj0e20gN1CLd4R
nIwWdKiLwOsRA3uSgcKDl9APqGyrzwDiDIYBRu6/jbFqSYcmZ0xhc4ekPMlwdYxW
mWGimIUIUtx7XqZpWz+hAwxgB7Bfc+Ur2xmJEs0Y7/9nxqmWEUWeG/bV1W4KLpLn
svZ1fcSih9sPHwgs6dtqDspw4THUlHp2rhTpqqvo6G1qLh4MTxGigqBrZnXaIrps
eg2VUjYrk+R6UmmFmpVXeqeZcLeQxN4GUab3xx+EUFTcViCa7OFtl84Xk72tu2k=
=DWl7
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Doing NMEA command sequences with zsh ... ??!!
2014-10-13 17:27 ` Vasiliy Ivanov
@ 2014-10-14 3:02 ` Bart Schaefer
0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2014-10-14 3:02 UTC (permalink / raw)
To: zsh-users
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-10-14 3:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-13 15:58 Doing NMEA command sequences with zsh ... ??!! meino.cramer
2014-10-13 17:27 ` Vasiliy Ivanov
2014-10-14 3:02 ` Bart Schaefer
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).