プログラムの書式

プログラムの書式
 HELP から プログラムが #C00以降に保存されることがわかる
 プログラムは どのような形式で保存されるのだろうか
 そこで プログラムの保存書式を調べるプログラムをつくる

10 'ABCD
20 '1234
30 FOR J=0 TO 21
40 D=PEEK(#C00+J)
45 PRINT HEX$(#C000+J);" ";
50 PRINT D;" ";
60 IF D<10 THEN ?" ";
70 IF D<32 THEN D=32
80 PRINT CHR$(D)
90 NEXT

 実行結果

f:id:nearbridge2:20190625131413j:plain:w300

       
  プログラムの実行結果

C000 10 行番号(2進法 下8桁)
C001 0 行番号( 2進法 上8桁)
C002 6 文字数
C003 39 '
C004 65 A
C005 66 B
C006 67 C
C007 68 D
C008 0 文字数調整
C009 0 行末
C00A 20 行番号( 2進法 下8桁)
C00B 0 行番号( 2進法 上8桁)
C00C 6 文字数
C00D 39 '
C00E 49 1
C00F 50 2
C010 51 3
C011 52 4
C012 0 文字数調整
C013 0 行末
C014 30 行番号( 2進法 下8桁)
C015 0 行番号( 2進法 上8桁)


行番号を変えてみると

255 'ABCD
265 '1234
275 FOR J=0 TO 21
285 D=PEEK(#C00+J)
295 PRINT HEX$(#C000+J);" ";
305 PRINT D;" ";
315 IF D<10 THEN ?" ";
325 IF D<32 THEN D=32
335 PRINT CHR$(D)
345 NEXT
       
 
 プログラムの実行結果

f:id:nearbridge2:20190703090915j:plain:w300

C000 255 行番号(2進法 下8桁)
C001 0 行番号(2進法 上8桁)
C002 6
C003 39 '
C004 65 A
C005 66 B
C006 67 C
C007 68 D
C008 0
C009 0
C00A 9 行番号(2進法 下8桁)
C00B 1 行番号( 2進法 上8桁)
C00C 6
C00D 39 '
C00E 49 1
C00F 50 2
C010 51 3
C011 52 4
C012 0
C013 0
C014 19 行番号(2進法 下8桁)
C015 1 行番号(2進法 上8桁)

行番号255が 255 , 0 なのは 理解できる
行番号265が 9 , 1 なのは どういうことだろうか

PRINT BIN$(265,16) を実行すると 00000001 00001001 である
00000001 は10進法で 1 00001001 は 10進法で 9

265 の行番号は 16ビットのCで表される
下位の8ビットは #C00A に 10進法で書き込まれる
上位の8ビットは #C00B に 10進法で書き込まれる 

この記法は 16ビットのデータを 8ビットのメモリ2つで表すのに
下位の 8 ビットを先に書いている
この記法を 「リトル・エンデアン」 という 
リトル・インデアン と思っていたら 違う 正しくは Little endian
 

ガリバー旅行記

 この齢(年齢非公開)になって ガリバー旅行記を読むことになった
 原題は Gulliver's Travels
 子供の頃 えほんで読んだが  絵本と原著は似ているが 同じではない
 

f:id:nearbridge2:20190702103202j:plain:w200

 ガリバーは 若き日にロンドンで航海術と数学を学ぶ のちにライデンに留学して 医学を学び船医となる
 南太平洋を目指す船の船医となり 1699年 ブリストルを出帆する
 暴風雨に会い難破して リリパット(小人国)に漂着する
 リリパット帝国は 700 mの海峡を隔てた ブレスキュ帝国と対立している
 原因は ゆで卵の殻のむきかたである
 リリパットでは 殻の小さい端を割る
 ブレスキュでは 殻の大きい端を割る

 それで リリパットを Little endian
 ブレスキュを Big endian という 





 

CoolTerm
https://freeware.the-meiers.org よりダウンロード

使い方は HELP に書いてあります

CoolTerm の画面

f:id:nearbridge2:20190629071820j:plain:w300

Cool Term の設定
Options から Serial Port

f:id:nearbridge2:20190629072104j:plain:w300

Serial Port Options
Select the serial port from the popup menu and configure its settings according to the requirements (Baudrate, Data Bits, Parity, etc.) of the connected hardware.
If the serial port to be used is not listed in the popup menu (e.g. in case it is a USB to Serial port adapter that was connected after CoolTerm was started) push the Re-Scan Serial Ports button. Should the serial port still not be available for selection, ensure that the proper drivers for the serial port are installed.
Additional information (such as driver names and rated speeds) about the selected port can be displayed by clicking the bevel button to the right side of the Port: popup menu.

Initial Line States when Port opens
This can be used to set the initial state of the RTS and DTR status lines when the respective hardware flowcontrol options are not enabled.

Terminal

f:id:nearbridge2:20190629072131j:plain:w300

Terminal
Options related to terminal behavior are adjusted here. These options are accessible regardless of the connection state of the serial port.

Terminal Options
Terminal Mode
Sets the operating mode of the terminal. In Raw Mode every key is sent via the serial port immediately as it is pressed. When in Line Mode, a command line field is visible in the terminal window. Characters typed in this field are added to a send buffer. The contents of the send buffer (i.e. one line of text) are sent when the enter key is pressed.
Line Mode supports History. I.e. the up and down arrow keys can be used to send previously typed lines. Alternatively, the square button to the right of the command line field can be pressed to show a history of previously sent lines. Select any line to add it to the send buffer.

Enter Key Emulation
Defines what character(s) to send when the Enter key is pressed. When in Line Mode, the contents of the send buffer are terminated with the character(s) selected here before they are sent.

Local Echo
If checked, locally entered data will be echoed in the terminal window.

Replace TAB key with spaces
If checked, TAB key presses are replaced with the number of spaces specified in the field below. Default is 4, with a maximum of 32.

Special Character Handling
Format TAB separated text
If enabled, text will be aligned on a specified column width in plain text view by replacing received TAB characters with spaces. The column width can be specified in the field below.

Replace Consecutive Spaces with TAB
If checked, consecutive space characters will be replaced by single TAB characters. The minimum number of consecutive spaces required for replacement can be specified below.

Filter ASCII Escape Sequences (ASCII View)
If checked, ASCII Escape Sequences will be removed from the received data in ASCII view mode.

Convert Non-printable Characters (ASCII View)
If checked, non-printable characters (ASCII codes 0 to 31) will be displayed as a period character in ASCII View mode.

Handle BS and DEL Characters
If checked, Backspace (BS, ASCII code 0x08) and Delete (DEL, ASCII 0x7f) characters will be visually handled in ASCII View mode. When either character is received (or typed with local echo enabled) the previous character in the ASCII viewer is deleted.

Handle Bell Character
If checked, received bell characters (ASCII code 7) will play a terminal beep.

Handle Form Feed Character
If checked, the reception of a FF character (ASCII code 12) will clear previously received characters from the receive buffer and thus clear the screen.

Handle End Of Text Character
Enabling this feature will prevent the display from updating until a EOT (ASCII code 4) character is received, at which time the display is updated with the contents from the receive buffer.
If Local Echo is enabled while this feature is enabled as well, locally echoed characters will cause the display to refresh immediately.

Ignore Line Feed Character
Enabling this feature will ignore received LF characters (ASCII code 10) and will prevent CoolTerm from interpreting rogue LF characters as new line characters.

Use UTF-8 to display plain text
Enables displaying plain text using UTF-8 encoding for received data in UTF-8 format.
Note that UTF-8 may not be supported for all platforms and/or font selection. Other special character handling may also impact UTF-8 display.

Receive

f:id:nearbridge2:20190629072147j:plain:w300

Receive
Settings with regard to received data can be adjusted here. These options are accessible regardless of the connection state of the serial port.

Receive Options
Loop back received data
If checked, all received data will be echoed back to the sender. This is a useful feature e.g. when working with hardware that has a built-in selftest which requires a loopback adapter. CoolTerm can act as such a loopback adapter and it allows for the data to be observed in the terminal window.

Ignore receive signal errors
If un-checked, CoolTerm will notify the users of signal errors (e.g. an attached device toggles a line state unexpectedly) and close the serial port. If checked, such errors will be ignored and the serial port will remain open.

Receive Buffer Size
The receive buffer, i.e. the amount of data being retained by the terminal window at any given time, is limited to the number of characters specified by this value. To avoid slow performance as the receive buffer fills up, this number should be kept small. The receive buffer size is limited to 2,147,483,647 (2GB) Bytes or less on systems with less available memory.
For use cases where CoolTerm is operated on a battery powered computer, it is also recommended to keep the receive buffer as small as possible in order to reduce strain on the CPU.

Capture Text Options
The Capture raw data and Capture data in Hex format selections determine how received data is stored in the capture file. Raw data capture is suitable when a true representation of the received date is to be captured. Capturing data Hex format provides a way of recording binary data in a more human readable form.

Add timestamps to received data
This option is suited for data logging applications. Timestamps are added whenever new data is available, i.e. a new DataAvailable events generated by the serial port API.

Wait for termination string
If enabled, CoolTerm will inspect received data for the specified termination string and only generate a timestamp and capture the data to file when such a string is received. This is useful for datalogging equipment that terminate their data with specific characters such as CR+LF. Enabling this option will log one line of data each time the termination string is received.

Termination String
This specifies the termination string CoolTerm expects to receive before capturing data to file, if Wait for termination string is enabled.

Type
This specifies the timestamp type. The following types are available:

  • Absolute Date and Time: The current date and time. The format is per the CoolTerm preferences setting.
  • Absolute Time: The current time only. The format is per the CoolTerm preferences setting.
  • Relative Time: The time that has passed since the start of capture, with millisecond resolution. The format is as follows: HH:MM:SS.sss, where sss denotes milliseconds.

Capture Local Echo
If checked, the local echo (if enabled in the Terminal Options) of transmitted data will be captured in addition to the received data.

Leave File open while capturing
If checked (default), CoolTerm will maintain a lock on the capture file by leaving it open as long as capturing is in progress.
If unchecked, the file will be closed each time after writing to it, and reopened when new data arrives. This allows other applications to read the contents of the capture file while capturing is in progress. This can be useful in automated environments where received data needs to be available to other applications.
NOTE: This option should be used with caution. The capture file should only be opened "read-only" by other applications so that CoolTerm can write new data to it.

Autostart on open
If enabled, capturing to text file is started automatically after the connection settings are loaded. The path to where the data is stored can be set via the Capture File Location field below.

Append to auto capture file
If disabled (default), a new auto capture file is created each time auto capture is started (i.e. each time the connection settings are loaded). A new auto capture file name will be time stamped with the time at which the file was created.
If this option is enabled and a capture file already exists, CoolTerm will append new data to the existing file.
If this option is enabled and a capture file does not already exist, CoolTerm will create one in the specified location.
NOTE: This option should not be enabled for connection settings that are saved as default.

Auto Capture File Name
Specifies a custom file name auto capture files when “Append to auto capture file” is enabled. Leave this field blank to let CoolTerm choose the default auto capture file name.
When “Append to auto capture file” is disabled, CoolTerm will choose the Auto Capture File Name automatically.

Transmit

f:id:nearbridge2:20190629072207j:plain:w300

Transmit
Settings with regard to transmission of data can be adjusted here. These options are accessible regardless of the connection state of the serial port.

Transmit Options
Use transmit character delay
Checking this option enables a character delay specified by the value (in milliseconds) in the Delay text field below. This option guarantees a minimum time between characters to support targets with limited or no receive buffering in order to avoid data loss during transmission. This option is also recommended for targets that employ CTS flow control. At least 3ms delay between characters should be allowed for software and hardware latency on the PC side to shut off data flow when using a CTS command. The maximum character delay that can be specified is 10,000ms.

Use transmit line delay
Checking this option enables a delay specified by the value (in milliseconds) in the Delay text field below. This option guarantees a minimum time after any character specified in the Delay characters text field below. The default is the Line Feed character (ASCII 10, or 0A hex). This supports targets that execute commands upon receipt of such a character and won't be able to process new data for a certain amount of time. The maximum line delay that can be specified is 10,000ms.

Send String Options
Terminate 'Send String' Data
Enables automatic termination of strings sent by Send String windows with a configurable Termination String. When pressing Send in any Send String window, the Termination String is automatically appended to the sent data.

Termination String
If enabled, this String is automatically appended when sending data from Send String windows.

Send Text Options
Notify after sending text files
If enabled, a short notification sound will be played upon completion of sending a text file.

Miscellaneous

f:id:nearbridge2:20190629183455j:plain:w300

Miscellaneous
Misc. Options
Automatically connect on open
If checked, the specified serial port will automatically open if these connection settings are loaded via the File/Open menu item. If this option is enabled in the 'default.stc' connection options file in the CoolTerm application directory, the serial port will be opened automatically whenever a new terminal is opened. Note, that each physical serial port can only be opened once, i.e. if a port is already opened, attempts to open the same port in another terminal window will cause a connection error.

Automatically disconnect on close
If checked, the serial port is closed automatically when the terminal window is being closed. If unchecked, CoolTerm will warn the user if it is attempted to close the window while the connection is still open.

Reduce Display Refresh Rate
If checked, this option reduces the terminal refresh rate to once per second, i.e. status texts, status LEDs, as well as displayed serial data are only refreshed once per second. This is useful to reduce strain on the CPU in setups where CoolTerm is operated on a battery powered computer. Note that this will not reduce the rate at which CoolTerm receives data, it only reduces the rate at which it is displayed.

USB モジュールについて :
チップ CP210x
IchigoJam 向け USB-シリアルモジュール 1,150円  (ショップのふうせん)

100円+コンピュータ(7)

プログラム・リストや実行結果の写真を撮るのが 面倒で USB-シリアル・モジュールを追加します ショップのふうせんから購入 +1,150円

f:id:nearbridge2:20190628140029j:plain:w300

CoolTerm コンソール

 IchigoJam に USB-シリアル・モジュールを追加したのは コンピュータとの接続が目的
 コンピュータのソフトウエアは CoolTerm (フリーのソフトウエア)

f:id:nearbridge2:20190628193808j:plain:w300

CoolTerm のおかげで
・プログラムのプリントができる
・プログラムを 文章にのせられる
・今まで 画面におさまらなかったプログラムを スクロールして 全体を見渡せる

 作業の能率が 格段によくなりました


 

100円+コンピュータ(6)
100 円コンピュータは その後基板を交換(約 2000 円)スピーカー(100円)を追加したので
支出は 約 2200 円 です

f:id:nearbridge2:20190616170153j:plain:w300

 AC アダプタ(12V)を使わないときは ケースのなかに ベルクロ(面ファスナー)で固定します

 FINDER の改良
 VER. 2.0 のバグ(F3 の表示 不具合)を修正しました
 現在のバージョンは 2.1 です

f:id:nearbridge2:20190625110020j:plain:w300

・200行 VPEEK( , )<>32 空白でなければ LC ., ?CHR$(14) でスペースをいれて 行を右にシフト
・CHR$(14) は ASCIIコード内の制御コードです 

f:id:nearbridge2:20190625110125j:plain:w300
f:id:nearbridge2:20190625110131j:plain:w300


FINDER の使い方 :

f:id:nearbridge2:20190618052659j:plain:w300

・F0 〜 F116 までのファイル名を表示
・0〜116 を入力 → そのプログラムが起動
・117 以上を入力 → 次のページを表示
・マイナスの値を入力 → ESCAPE

f:id:nearbridge2:20190618052302j:plain:w300

・F117 から F57までのファイル名を表示
・0-116 を入力 → そのプログラムが起動
・マイナスの値を入力 → ESCAPE
・116 以下を入力 → 前のページを表示

ASCII コードについて:
  ASCII コードは コンピュータで文字や数字などを扱うための規格です
 0〜255 の数に 文字数字などをあてはめています
 32 〜 47 記号
 48 〜 57 数字
 58 〜 64 記号
 65 〜 90 英字 大文字 
 91 〜 96 記号
 97 〜 122 英字 小文字
 123 〜 127 記号
 128 〜 255 拡張文字コード

 0 〜 31 は 制御コードです(文字や記号ではない)
 bell, shift in, carriage return などが 含まれています
 その昔 データ通信にテレタイプが使われていた その名残です

 IchigoJam BASIC では 0 〜 31 を 制御・特殊コードとして 使用しています