[GreenKeys] OT - python (was 33 Emulator)
Hugh Pyle
hpyle at cabezal.com
Sat Jul 11 10:16:22 EDT 2020
Python 'int' is arbitrary size, so you can't use it for fixed-size
bitfields without maybe a class to impose some constraints. It does have
the usual C-style bitwise operators for shifting and so on (
https://wiki.python.org/moin/BitwiseOperators).
There are a couple versions of Python that have become popular on embedded
systems (CircuitPython and MicroPython) where I expect these operations are
common. But I don't know whether they kept the unlimited-size int, or have
special functions for bitwise operations.
At the other extreme is the 'numpy' package, popular for data analytics --
numpy has amazing features for dealing with multidimensional arrays, and
also has storage-efficient datatypes ("int64" and the like), so it might be
worth investigating.
-Hugh
On Sat, Jul 11, 2020 at 12:11 AM Gil Smith <gil at baudot.net> wrote:
> Hi Hugh:
>
> That is a fun emulator indeed. I have been starting to look into python
> but am a total noob, so I understood some of your code, but there is so
> much to learn.
>
> I want to manipulate data as I do in C but one stumbling block I have with
> python is the simple ubiquitous int. In C I need to be able to declare, as
> needed, unsigned uint8_t or signed int8_t for a fundamental byte of storage
> or io (likewise with 16- or 32-bit data).
>
> Often I need to work with unsigned numbers of a specific size, and when I
> am working with signed 2s-complement, it may be 12 bits from a temperature
> sensor that I need to put into an int16_t, or 24 bits from and adc which I
> need to put into an int32_t, and I need sign-extension. I see no way to
> represent specific-sized data like that in python.
>
> I had the same problem in java some time back with a simple unsigned byte that
> I needed to send out an i2c port. Like python, java does not understand
> an unsigned number. I hacked around it in java with a clunky method that
> hid the ugliness of enforcing 0 to 255 limits for what was to be a
> uint8_t. But yuk.
>
> I need to cast to promote or truncate, shift bits, mask, combine, etc. In
> python all I have found so far is a way to convert the all-purpose int to
> hex or binary strings -- not anything close to something workable for
> bare-metal programming.
>
> Am I missing something fundamental, or a wonderful module I can import to
> let me manipulate data the way I love to do in C?
>
> thx, gil
>
>
> gil smith, AF7EZ
> greenkeys moderator
> gil at baudot.net
>
>
> -------- Original Message --------
> Subject: [GreenKeys] 33 Emulator
> From: Hugh Pyle <hpyle at cabezal.com>
> Date: Fri, July 10, 2020 1:32 pm
> To: Greenkeys <GreenKeys at mailman.qth.net>
>
> Almost better than the real thing: a Model 33 terminal emulator. This is
> not my project, originally; but this week I've added sound effects, and I
> think the result is quite nicely realistic. You can even open and close
> the lid.
>
> Video: https://youtu.be/jd5oomwEBb0
> Code: https://github.com/hughpyle/ttyemu
>
> There's not much documentation in the project yet, so you'll need to be
> quite familiar with Python to get it running. Happy to help if anyone gets
> stuck trying.
>
> -Hugh
>
> ------------------------------
> ______________________________________________________________
> GreenKeys mailing list
> Home: http://mailman.qth.net/mailman/listinfo/greenkeys
> Help: http://mailman.qth.net/mmfaq.htm
> Post: mailto:GreenKeys at mailman.qth.net <GreenKeys at mailman.qth.net>
>
> >>> Jordan Spencer Cunningham's GreenKeys Search Tool:
> https://teletype.net/gksearch
> >>> 2002-to-present greenkeys archive:
> http://mailman.qth.net/pipermail/greenkeys/
> >>> 1998-to-2001 greenkeys archive:
> http://mailman.qth.net/archive/greenkeys/greenkeys.html
> >>> Randy Guttery's 2001-to-2009 GreenKeys Search Tool:
> http://comcents.com/tty/greenkeyssearch.html
>
> This list hosted by: http://www.qsl.net
> Please help support this email list: http://www.qsl.net/donate.html
> Message delivered to gil at baudot.net
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qth.net/pipermail/greenkeys/attachments/20200711/7cdc6fe1/attachment.html>
More information about the GreenKeys
mailing list