All BASIC

Message Boards => Scripting Languages => Topic started by: John on March 15, 2019, 06:26:01 PM

Title: SB π
Post by: John on March 15, 2019, 06:26:01 PM
I just ordered a Raspberry Pi as a Script BASIC development device. The first job my Pi gets is being a full time Samba Windows network environment.

(https://m.media-amazon.com/images/S/aplus-seller-content-images-us-east-1/ATVPDKIKX0DER/AHALS71WJO58T/f99834b9-caf1-4d09-a8d4-ae96c5c003dd._CR0,0,970,600_PT0_SX970__.jpg)

AIR,

If I remember correctly you already have SB compiled for the Pi? If so can you point to a link or attach a zip for me?
Title: Re: SB Pi
Post by: AIR on March 15, 2019, 09:02:57 PM
https://www.allbasic.info/forum/index.php?topic=532.msg5924#msg5924

rudimentary appimage.

The perl build scripts work on the rpi, so you have that option as well after setting up the dev environment.
Title: Re: SB Pi
Post by: John on March 15, 2019, 09:20:08 PM
Thanks AIR!

I'm looking forward to it arriving by Thursday next week.

My first task is to create a GPIO extension module. Do you know of a good C library that might be easy to use?

I hope the SBT extension module works as this would be a good thread model for SB.
Title: Re: SB Pi
Post by: John on March 15, 2019, 10:13:22 PM
Good News!

One of our members (Gordon) and also a BASIC developer (RTB) has a C GPIO library.

WiringPi (http://wiringpi.com/)

Gordon's last post (https://www.allbasic.info/forum/index.php?topic=223.msg5453#msg5453)
Title: Re: SB Pi
Post by: John on March 17, 2019, 02:06:02 PM
I thought I would get a head start and install the Raspberry Pi Desktop in a Virtualbox.

Quote
Debian with Raspberry Pi Desktop is the Foundationís operating system for PC and Mac. You can create a live disc, run it in a virtual machine, or even install it on your computer.

Raspberry Pi Desktop comes pre-installed with plenty of software for education, programming and general use; including Python, Scratch, Sonic Pi, Java, and more.

I wonder li I can cross compile to ARM from this VM?

(https://files.allbasic.info/rpi/Rasberry_Pi_3_B_VirtualBox.png)
Title: Re: SB Pi
Post by: AIR on March 17, 2019, 08:50:57 PM
This may help get you started:

The Useful RaspberryPi Cross Compile Guide (https://medium.com/@au42/the-useful-raspberrypi-cross-compile-guide-ea56054de187)
Title: Re: SB Pi
Post by: John on March 17, 2019, 09:08:01 PM
Thanks AIR!

Quote
For this example Iím going to be using the standard pthreads library, a locally-compiled open-source wiringPi library, and the current C11 standard with our compile

This answers my questions about SBT and using Gordon's WiringPi library.  8)
Title: Re: SB Pi
Post by: John on March 18, 2019, 06:17:59 PM
Raspberry Pi Desktop has a cool GPIO emulator with an array of sensors. It's programable using the Python examples included. Sounds like a great way to develop GPIO applications and not need the physical interface or sensor modules.
Title: Re: SB Pi
Post by: John on March 18, 2019, 06:34:40 PM
AIR,

Do you think your Raspberry Pi AppImage of Script BASIC would run on my Samsung S8+ in a Connect Bot terminal session? I already have Busybox Linux utilities installed.

I have an Android SB I compiled native on a rooted Samsung Galaxy Tab 10.5. Getting libcurl to compile was a challenge.
Title: Re: SB Pi
Post by: AIR on March 18, 2019, 07:34:39 PM
I don't think so, I think the underlying architectures are different...only one way to find out.

Also, some of the required support libraries might not be present.
Title: Re: SB Pi
Post by: John on March 20, 2019, 12:42:46 PM
My Pi arrived.

Update with getting it running to come shortly.
Title: Re: SB Pi
Post by: John on March 20, 2019, 02:03:22 PM
Hi from my Pi.

Linux raspberrypi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux

I'm happy with the Raspberry kit I ordered and everything went smoothly getting up and going.

Next is getting SB going on the Pi.


pi@raspberrypi:~ $ sb -v
ScriptBasic v2.1
Variation >>STANDARD<< build 1
Magic value 859037497
Node size is 24
Extension interface version is 11
Compilation: Nov 29 2018 00:44:51
pi@raspberrypi:~ $

 :)  8)
Title: Re: SB Pi
Post by: John on March 20, 2019, 04:05:17 PM
AIR,

I tried myip.sb on my RPi using your AppImage and it just hung. Do I need to install libcurl to get it to work?

Even this simple program hangs.  :-\

Code: Script BASIC
  1. PRINT "It works!\n"
  2.  

pi@raspberrypi:~ $ sb -D
dll ".so"
module "/tmp/.mount_sb6wlVhb/module/"
include "/tmp/.mount_sb6wlVhb/include/"
maxstep 0
maxlocalstep 0
maxlevel 29666
maxmem 0
pi@raspberrypi:~ $

FYI: I put the sb AppImage in my /user/bin directory for global use.
Title: Re: SB Pi
Post by: John on March 20, 2019, 06:36:27 PM
I was able to rebuild Script BASIC from source and it looks like everything compiled without error.

Code: Text
  1. pi@raspberrypi:~ $ sudo apt install libcurl4-gnutls-dev
  2. Reading package lists... Done
  3. Building dependency tree      
  4. Reading state information... Done
  5. Suggested packages:
  6.   libcurl4-doc libcurl3-dbg libgnutls28-dev libidn11-dev libkrb5-dev libldap2-dev librtmp-dev libssh2-1-dev
  7. The following NEW packages will be installed:
  8.   libcurl4-gnutls-dev
  9. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  10. Need to get 326 kB of archives.
  11. After this operation, 998 kB of additional disk space will be used.
  12. Get:1 http://mirrors.syringanetworks.net/raspbian/raspbian stretch/main armhf libcurl4-gnutls-dev armhf 7.52.1-5+deb9u9 [326 kB]
  13. Fetched 326 kB in 1s (199 kB/s)              
  14. Selecting previously unselected package libcurl4-gnutls-dev:armhf.
  15. (Reading database ... 80861 files and directories currently installed.)
  16. Preparing to unpack .../libcurl4-gnutls-dev_7.52.1-5+deb9u9_armhf.deb ...
  17. Unpacking libcurl4-gnutls-dev:armhf (7.52.1-5+deb9u9) ...
  18. Processing triggers for man-db (2.7.6.1-2) ...
  19. Setting up libcurl4-gnutls-dev:armhf (7.52.1-5+deb9u9) ...
  20. pi@raspberrypi:~ $ sudo apt install libiodbc2-dev
  21. Reading package lists... Done
  22. Building dependency tree      
  23. Reading state information... Done
  24. The following additional packages will be installed:
  25.   libiodbc2
  26. Suggested packages:
  27.   iodbc
  28. The following NEW packages will be installed:
  29.   libiodbc2 libiodbc2-dev
  30. 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
  31. Need to get 185 kB of archives.
  32. After this operation, 618 kB of additional disk space will be used.
  33. Do you want to continue? [Y/n] Y
  34. Get:1 http://raspbian-us.ngc292.space/raspbian stretch/main armhf libiodbc2 armhf 3.52.9-2 [129 kB]
  35. Get:2 http://raspbian.mirror.constant.com/raspbian stretch/main armhf libiodbc2-dev armhf 3.52.9-2 [56.4 kB]
  36. Fetched 185 kB in 2s (66.4 kB/s)                                            
  37. Selecting previously unselected package libiodbc2:armhf.
  38. (Reading database ... 80886 files and directories currently installed.)
  39. Preparing to unpack .../libiodbc2_3.52.9-2_armhf.deb ...
  40. Unpacking libiodbc2:armhf (3.52.9-2) ...
  41. Selecting previously unselected package libiodbc2-dev.
  42. Preparing to unpack .../libiodbc2-dev_3.52.9-2_armhf.deb ...
  43. Unpacking libiodbc2-dev (3.52.9-2) ...
  44. Setting up libiodbc2:armhf (3.52.9-2) ...
  45. Processing triggers for man-db (2.7.6.1-2) ...
  46. Setting up libiodbc2-dev (3.52.9-2) ...
  47. pi@raspberrypi:~ $ sudo apt install libmariadbclient-dev-compat
  48. Reading package lists... Done
  49. Building dependency tree      
  50. Reading state information... Done
  51. The following additional packages will be installed:
  52.   libmariadbclient-dev libmariadbclient18 mysql-common
  53. The following NEW packages will be installed:
  54.   libmariadbclient-dev libmariadbclient-dev-compat libmariadbclient18 mysql-common
  55. 0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
  56. Need to get 2,321 kB of archives.
  57. After this operation, 13.3 MB of additional disk space will be used.
  58. Do you want to continue? [Y/n] Y
  59. Get:1 http://mirrors.syringanetworks.net/raspbian/raspbian stretch/main armhf mysql-common all 5.8+1.0.2 [5,608 B]
  60. Get:2 http://mirror.us.leaseweb.net/raspbian/raspbian stretch/main armhf libmariadbclient18 armhf 10.1.37-0+deb9u1 [714 kB]
  61. Get:3 http://mirror.us.leaseweb.net/raspbian/raspbian stretch/main armhf libmariadbclient-dev armhf 10.1.37-0+deb9u1 [1,574 kB]
  62. Get:4 http://mirror.us.leaseweb.net/raspbian/raspbian stretch/main armhf libmariadbclient-dev-compat armhf 10.1.37-0+deb9u1 [27.1 kB]
  63. Fetched 2,321 kB in 2s (775 kB/s)                      
  64. Selecting previously unselected package mysql-common.
  65. (Reading database ... 80926 files and directories currently installed.)
  66. Preparing to unpack .../mysql-common_5.8+1.0.2_all.deb ...
  67. Unpacking mysql-common (5.8+1.0.2) ...
  68. Selecting previously unselected package libmariadbclient18:armhf.
  69. Preparing to unpack .../libmariadbclient18_10.1.37-0+deb9u1_armhf.deb ...
  70. Unpacking libmariadbclient18:armhf (10.1.37-0+deb9u1) ...
  71. Selecting previously unselected package libmariadbclient-dev.
  72. Preparing to unpack .../libmariadbclient-dev_10.1.37-0+deb9u1_armhf.deb ...
  73. Unpacking libmariadbclient-dev (10.1.37-0+deb9u1) ...
  74. Selecting previously unselected package libmariadbclient-dev-compat:armhf.
  75. Preparing to unpack .../libmariadbclient-dev-compat_10.1.37-0+deb9u1_armhf.deb ...
  76. Unpacking libmariadbclient-dev-compat:armhf (10.1.37-0+deb9u1) ...
  77. Setting up mysql-common (5.8+1.0.2) ...
  78. update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
  79. Setting up libmariadbclient18:armhf (10.1.37-0+deb9u1) ...
  80. Processing triggers for libc-bin (2.24-11+deb9u4) ...
  81. Processing triggers for man-db (2.7.6.1-2) ...
  82. Setting up libmariadbclient-dev (10.1.37-0+deb9u1) ...
  83. Setting up libmariadbclient-dev-compat:armhf (10.1.37-0+deb9u1) ...
  84. pi@raspberrypi:~ $ sudo apt install libncurses5-dev
  85. Reading package lists... Done
  86. Building dependency tree      
  87. Reading state information... Done
  88. The following additional packages will be installed:
  89.   libtinfo-dev
  90. Suggested packages:
  91.   ncurses-doc
  92. The following NEW packages will be installed:
  93.   libncurses5-dev libtinfo-dev
  94. 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
  95. Need to get 311 kB of archives.
  96. After this operation, 1,469 kB of additional disk space will be used.
  97. Do you want to continue? [Y/n] Y
  98. Get:1 http://raspbian.mirror.constant.com/raspbian stretch/main armhf libtinfo-dev armhf 6.0+20161126-1+deb9u2 [65.6 kB]
  99. Get:2 http://mirror.us.leaseweb.net/raspbian/raspbian stretch/main armhf libncurses5-dev armhf 6.0+20161126-1+deb9u2 [245 kB]
  100. Fetched 311 kB in 1s (184 kB/s)                                    
  101. Selecting previously unselected package libtinfo-dev:armhf.
  102. (Reading database ... 81299 files and directories currently installed.)
  103. Preparing to unpack .../libtinfo-dev_6.0+20161126-1+deb9u2_armhf.deb ...
  104. Unpacking libtinfo-dev:armhf (6.0+20161126-1+deb9u2) ...
  105. Selecting previously unselected package libncurses5-dev:armhf.
  106. Preparing to unpack .../libncurses5-dev_6.0+20161126-1+deb9u2_armhf.deb ...
  107. Unpacking libncurses5-dev:armhf (6.0+20161126-1+deb9u2) ...
  108. Setting up libtinfo-dev:armhf (6.0+20161126-1+deb9u2) ...
  109. Setting up libncurses5-dev:armhf (6.0+20161126-1+deb9u2) ...
  110. Processing triggers for man-db (2.7.6.1-2) ...
  111. pi@raspberrypi:~ $ sudo apt install libsqlite3-dev
  112. Reading package lists... Done
  113. Building dependency tree      
  114. Reading state information... Done
  115. Suggested packages:
  116.   sqlite3-doc
  117. The following NEW packages will be installed:
  118.   libsqlite3-dev
  119. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  120. Need to get 613 kB of archives.
  121. After this operation, 1,702 kB of additional disk space will be used.
  122. Get:1 http://mirror.umd.edu/raspbian/raspbian stretch/main armhf libsqlite3-dev armhf 3.16.2-5+deb9u1 [613 kB]
  123. Fetched 613 kB in 1s (374 kB/s)        
  124. Selecting previously unselected package libsqlite3-dev:armhf.
  125. (Reading database ... 81348 files and directories currently installed.)
  126. Preparing to unpack .../libsqlite3-dev_3.16.2-5+deb9u1_armhf.deb ...
  127. Unpacking libsqlite3-dev:armhf (3.16.2-5+deb9u1) ...
  128. Setting up libsqlite3-dev:armhf (3.16.2-5+deb9u1) ...
  129. pi@raspberrypi:~ $ sudo apt install libssl-dev
  130. Reading package lists... Done
  131. Building dependency tree      
  132. Reading state information... Done
  133. The following additional packages will be installed:
  134.   libssl-doc
  135. The following NEW packages will be installed:
  136.   libssl-dev libssl-doc
  137. 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
  138. Need to get 2,858 kB of archives.
  139. After this operation, 9,857 kB of additional disk space will be used.
  140. Do you want to continue? [Y/n] Y
  141. Get:1 http://raspbian.mirror.constant.com/raspbian stretch/main armhf libssl-dev armhf 1.1.0j-1~deb9u1 [1,383 kB]
  142. Get:2 http://raspbian.mirror.constant.com/raspbian stretch/main armhf libssl-doc all 1.1.0j-1~deb9u1 [1,476 kB]
  143. Fetched 2,858 kB in 25s (110 kB/s)                                                                                                                                                                                              
  144. Selecting previously unselected package libssl-dev:armhf.
  145. (Reading database ... 81359 files and directories currently installed.)
  146. Preparing to unpack .../libssl-dev_1.1.0j-1~deb9u1_armhf.deb ...
  147. Unpacking libssl-dev:armhf (1.1.0j-1~deb9u1) ...
  148. Selecting previously unselected package libssl-doc.
  149. Preparing to unpack .../libssl-doc_1.1.0j-1~deb9u1_all.deb ...
  150. Unpacking libssl-doc (1.1.0j-1~deb9u1) ...
  151. Setting up libssl-dev:armhf (1.1.0j-1~deb9u1) ...
  152. Processing triggers for man-db (2.7.6.1-2) ...
  153. Setting up libssl-doc (1.1.0j-1~deb9u1) ...
  154. pi@raspberrypi:~ $ sudo apt install zlib1g-dev
  155. Reading package lists... Done
  156. Building dependency tree      
  157. Reading state information... Done
  158. zlib1g-dev is already the newest version (1:1.2.8.dfsg-5).
  159. zlib1g-dev set to manually installed.
  160. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
  161. pi@raspberrypi:~ $
  162.  
  163. pi@raspberrypi:~/sb-dev-master $ ./setup
  164. This is unix cwd=/home/pi/sb-dev-master/
  165. creating configure.jim
  166. creating subdirectories for compilation output files
  167. compiling Makefile using the Jamal preprocessor
  168. running syntaxer.pl to generate the syntax defintion C language tables from syntax.def
  169. running generrh.pl to generate the error messages from errors.def
  170. running lmt_make.pl for all lmt*.def files
  171. scanning all subdirectories to find all C source files
  172. there are 3447 files in the source tree
  173. there are 123 C source files in the source tree
  174. configuring module sqlite
  175. ar: creating /home/pi/sb-dev-master/bin/mod/lib/sqlite.a
  176. This is unix cwd=/home/pi/sb-dev-master/
  177. executing headerer for the C files
  178.  extracting header from interface.c
  179. creating the module object directory
  180. Creating typical makefile.jam for the module
  181. file: interface.c
  182. determining dependency from extensions/sqlite/interface.c
  183. Processing jamal files creating makefile
  184. Module was compiled fine
  185. configuring module curses
  186. ar: creating /home/pi/sb-dev-master/bin/mod/lib/curses.a
  187. This is unix cwd=/home/pi/sb-dev-master/
  188. executing headerer for the C files
  189.  extracting header from interface.c
  190. creating the module object directory
  191. Creating typical makefile.jam for the module
  192. file: interface.c
  193. determining dependency from extensions/curses/interface.c
  194. Processing jamal files creating makefile
  195. Module was compiled fine
  196. configuring module zlib
  197. ar: creating /home/pi/sb-dev-master/bin/mod/lib/zlib.a
  198. This is unix cwd=/home/pi/sb-dev-master/
  199. executing headerer for the C files
  200.  extracting header from interface.c
  201. creating the module object directory
  202. Creating typical makefile.jam for the module
  203. file: interface.c
  204. determining dependency from extensions/zlib/interface.c
  205. Processing jamal files creating makefile
  206. Module was compiled fine
  207. configuring module slre
  208. ar: creating /home/pi/sb-dev-master/bin/mod/lib/slre.a
  209. This is unix cwd=/home/pi/sb-dev-master/
  210. executing headerer for the C files
  211.  extracting header from slre.c
  212.  extracting header from interface.c
  213. creating the module object directory
  214. Creating typical makefile.jam for the module
  215. file: slre.c
  216. file: interface.c
  217. determining dependency from extensions/slre/slre.c
  218. determining dependency from extensions/slre/interface.c
  219. Processing jamal files creating makefile
  220. Module was compiled fine
  221. configuring module dyc
  222. This is unix cwd=/home/pi/sb-dev-master/
  223. The module dyc is not for unix.
  224. executing headerer for the C files
  225.  extracting header from interface.c
  226. creating the module object directory
  227. Creating typical makefile.jam for the module
  228. file: interface.c
  229. determining dependency from extensions/dyc/interface.c
  230. Processing jamal files creating makefile
  231. configuring module ux
  232. ar: creating /home/pi/sb-dev-master/bin/mod/lib/ux.a
  233. This is unix cwd=/home/pi/sb-dev-master/
  234. executing headerer for the C files
  235.  extracting header from interface.c
  236. creating the module object directory
  237. Creating typical makefile.jam for the module
  238. file: interface.c
  239. determining dependency from extensions/ux/interface.c
  240. Processing jamal files creating makefile
  241. Module was compiled fine
  242. configuring module hash
  243. ar: creating /home/pi/sb-dev-master/bin/mod/lib/hash.a
  244. This is unix cwd=/home/pi/sb-dev-master/
  245. executing headerer for the C files
  246.  extracting header from interface.c
  247. creating the module object directory
  248. Creating typical makefile.jam for the module
  249. file: interface.c
  250. determining dependency from extensions/hash/interface.c
  251. Processing jamal files creating makefile
  252. Module was compiled fine
  253. configuring module nt
  254. This is unix cwd=/home/pi/sb-dev-master/
  255. The module nt is not for unix.
  256. executing headerer for the C files
  257.  extracting header from interface.c
  258. creating the module object directory
  259. Creating typical makefile.jam for the module
  260. file: interface.c
  261. determining dependency from extensions/nt/interface.c
  262. Processing jamal files creating makefile
  263. configuring module mxml
  264. ar: creating /home/pi/sb-dev-master/bin/mod/lib/mxml.a
  265. This is unix cwd=/home/pi/sb-dev-master/
  266. executing headerer for the C files
  267.  extracting header from mxml-entity.c
  268.  extracting header from mxml-file.c
  269.  extracting header from mxml-set.c
  270.  extracting header from mxml-node.c
  271.  extracting header from interface.c
  272.  extracting header from mxml-attr.c
  273.  extracting header from mxml-get.c
  274.  extracting header from mxml-string.c
  275.  extracting header from mxml-search.c
  276.  extracting header from mxml-index.c
  277.  extracting header from mxml-private.c
  278. creating the module object directory
  279. Creating typical makefile.jam for the module
  280. file: mxml-entity.c
  281. file: mxml-file.c
  282. file: mxml-set.c
  283. file: mxml-node.c
  284. file: interface.c
  285. file: mxml-attr.c
  286. file: mxml-get.c
  287. file: mxml-string.c
  288. file: mxml-search.c
  289. file: mxml-index.c
  290. file: mxml-private.c
  291. determining dependency from extensions/mxml/mxml-entity.c
  292. determining dependency from extensions/mxml/mxml-file.c
  293. determining dependency from extensions/mxml/mxml-set.c
  294. determining dependency from extensions/mxml/mxml-node.c
  295. determining dependency from extensions/mxml/interface.c
  296. determining dependency from extensions/mxml/mxml-attr.c
  297. determining dependency from extensions/mxml/mxml-get.c
  298. determining dependency from extensions/mxml/mxml-string.c
  299. determining dependency from extensions/mxml/mxml-search.c
  300. determining dependency from extensions/mxml/mxml-index.c
  301. determining dependency from extensions/mxml/mxml-private.c
  302. Processing jamal files creating makefile
  303. Module was compiled fine
  304. configuring module cio
  305. This is unix cwd=/home/pi/sb-dev-master/
  306. The module cio is not for unix.
  307. executing headerer for the C files
  308.  extracting header from interface.c
  309. creating the module object directory
  310. Creating typical makefile.jam for the module
  311. file: interface.c
  312. determining dependency from extensions/cio/interface.c
  313. Processing jamal files creating makefile
  314. configuring module mt
  315. ar: creating /home/pi/sb-dev-master/bin/mod/lib/mt.a
  316. This is unix cwd=/home/pi/sb-dev-master/
  317. executing headerer for the C files
  318.  extracting header from interface.c
  319. creating the module object directory
  320. Creating typical makefile.jam for the module
  321. file: interface.c
  322. determining dependency from extensions/mt/interface.c
  323. Processing jamal files creating makefile
  324. Module was compiled fine
  325. configuring module sdbg
  326. ar: creating /home/pi/sb-dev-master/bin/mod/lib/sdbg.a
  327. This is unix cwd=/home/pi/sb-dev-master/
  328. executing headerer for the C files
  329.  extracting header from interface.c
  330.  extracting header from sdbg_con.c
  331. creating the module object directory
  332. Creating typical makefile.jam for the module
  333. file: interface.c
  334. file: sdbg_con.c
  335. determining dependency from extensions/sdbg/interface.c
  336. determining dependency from extensions/sdbg/sdbg_con.c
  337. Processing jamal files creating makefile
  338. Module was compiled fine
  339. configuring module t
  340. ar: creating /home/pi/sb-dev-master/bin/mod/lib/t.a
  341. This is unix cwd=/home/pi/sb-dev-master/
  342. executing headerer for the C files
  343.  extracting header from interface.c
  344. creating the module object directory
  345. Creating typical makefile.jam for the module
  346. file: interface.c
  347. determining dependency from extensions/t/interface.c
  348. Processing jamal files creating makefile
  349. Module was compiled fine
  350. configuring module trial
  351. ar: creating /home/pi/sb-dev-master/bin/mod/lib/trial.a
  352. This is unix cwd=/home/pi/sb-dev-master/
  353. executing headerer for the C files
  354.  extracting header from interface.c
  355. creating the module object directory
  356. Creating typical makefile.jam for the module
  357. file: interface.c
  358. determining dependency from extensions/trial/interface.c
  359. Processing jamal files creating makefile
  360. Module was compiled fine
  361. configuring module dbg
  362. ar: creating /home/pi/sb-dev-master/bin/mod/lib/dbg.a
  363. This is unix cwd=/home/pi/sb-dev-master/
  364. executing headerer for the C files
  365.  extracting header from interface.c
  366.  extracting header from dbg_con.c
  367. creating the module object directory
  368. Creating typical makefile.jam for the module
  369. file: interface.c
  370. file: dbg_con.c
  371. determining dependency from extensions/dbg/interface.c
  372. determining dependency from extensions/dbg/dbg_con.c
  373. Processing jamal files creating makefile
  374. Module was compiled fine
  375. configuring module json
  376. ar: creating /home/pi/sb-dev-master/bin/mod/lib/json.a
  377. This is unix cwd=/home/pi/sb-dev-master/
  378. executing headerer for the C files
  379.  extracting header from interface.c
  380.  extracting header from parson.c
  381. creating the module object directory
  382. Creating typical makefile.jam for the module
  383. file: interface.c
  384. file: parson.c
  385. determining dependency from extensions/json/interface.c
  386. determining dependency from extensions/json/parson.c
  387. Processing jamal files creating makefile
  388. Module was compiled fine
  389. configuring module curl
  390. ar: creating /home/pi/sb-dev-master/bin/mod/lib/curl.a
  391. This is unix cwd=/home/pi/sb-dev-master/
  392. executing headerer for the C files
  393.  extracting header from interface.c
  394. creating the module object directory
  395. Creating typical makefile.jam for the module
  396. file: interface.c
  397. determining dependency from extensions/curl/interface.c
  398. Processing jamal files creating makefile
  399. Module was compiled fine
  400. configuring module mysql
  401. ar: creating /home/pi/sb-dev-master/bin/mod/lib/mysql.a
  402. This is unix cwd=/home/pi/sb-dev-master/
  403. executing headerer for the C files
  404.  extracting header from interface.c
  405. creating the module object directory
  406. Creating typical makefile.jam for the module
  407. file: interface.c
  408. determining dependency from extensions/mysql/interface.c
  409. Processing jamal files creating makefile
  410. Module was compiled fine
  411. configuring module ftpd
  412. This is unix cwd=/home/pi/sb-dev-master/
  413. The module ftpd is not for unix.
  414. executing headerer for the C files
  415.  extracting header from interface.c
  416. creating the module object directory
  417. Creating typical makefile.jam for the module
  418. file: interface.c
  419. determining dependency from extensions/ftpd/interface.c
  420. Processing jamal files creating makefile
  421. configuring module cgi
  422. ar: creating /home/pi/sb-dev-master/bin/mod/lib/cgi.a
  423. This is unix cwd=/home/pi/sb-dev-master/
  424. executing headerer for the C files
  425.  extracting header from cgi.c
  426.  extracting header from interface.c
  427. creating the module object directory
  428. Creating typical makefile.jam for the module
  429. file: cgi.c
  430. file: interface.c
  431. determining dependency from extensions/cgi/cgi.c
  432. determining dependency from extensions/cgi/interface.c
  433. Processing jamal files creating makefile
  434. Module was compiled fine
  435. configuring module odbc
  436. ar: creating /home/pi/sb-dev-master/bin/mod/lib/odbc.a
  437. This is unix cwd=/home/pi/sb-dev-master/
  438. executing headerer for the C files
  439.  extracting header from interface.c
  440. creating the module object directory
  441. Processing jamal files creating makefile
  442. Module was compiled fine
  443. making compile command file(s)
  444. starting compilation
  445. ar: creating /home/pi/sb-dev-master/bin/lib/lscriba.a
  446. ScriptBasic v2.1
  447. Variation >>STANDARD<< build 1
  448. Magic value 859036464
  449. Node size is 24
  450. Extension interface version is 11
  451. Compilation: Mar 20 2019 18:33:21
  452. mkdir: cannot create directory Ď/home/pi/sb-dev-master/bin/var/httpdí: File exists
  453. ar: creating /home/pi/sb-dev-master/bin/lib/libscriba.a
  454. scriba executable OK  
  455. sbhttpd executable OK  
  456. libscriba library OK  
  457. MODULE sqlite:   dll OK   lib OK   bas OK  
  458. MODULE curses:   dll OK   lib OK   bas OK  
  459. MODULE zlib:     dll OK   lib OK   bas OK  
  460. MODULE slre:     dll OK   lib OK   bas OK  
  461. MODULE ux:       dll OK   lib OK   bas OK  
  462. MODULE hash:     dll OK   lib OK   bas OK  
  463. MODULE mxml:     dll OK   lib OK   bas OK  
  464. MODULE mt:       dll OK   lib OK   bas OK  
  465. MODULE sdbg:     dll OK   lib OK   bas OK  
  466. MODULE t:        dll OK   lib OK   bas OK  
  467. MODULE trial:    dll OK   lib OK   bas OK  
  468. MODULE dbg:      dll OK   lib OK   bas OK  
  469. MODULE json:     dll OK   lib OK   bas OK  
  470. MODULE curl:     dll OK   lib OK   bas OK  
  471. MODULE mysql:    dll OK   lib OK   bas OK  
  472. MODULE cgi:      dll OK   lib OK   bas OK  
  473. MODULE odbc:     dll OK   lib OK   bas OK  
  474. pi@raspberrypi:~/sb-dev-master $
  475.  
Title: Re: SB Pi
Post by: John on March 20, 2019, 08:46:42 PM
AIR,

I just install my build as a system install and I have the same problem with scriba hanging as well.


scriba has no problem converting its text version of basic.conf to a binary format which -D displays. Just can't run scripts.  :-\

I once left scriba in its hang condition and it eventually it hug the OS as well. (memory being consumed?)

I just tested with task manage running and as soon as I run my simple test script the CPU and Memory rapidly became consumed. I remember when we were getting SB to run on Android there was a fix (can't remember his name) to the source for ARM. This sounds familiar.

What Raspberry Pi version do you have?


Title: Re: SB Pi
Post by: John on March 21, 2019, 07:32:30 AM
Peter Verhas is ecstatic about SB 'running' on the Raspberry Pi. This is the first time since I picked up the project have I seen him excited about his past effort.

It would be great if we can actually make it run. I think I spoke to soon assuming it did work.
Title: Re: SB Pi
Post by: John on March 22, 2019, 04:16:13 AM
Just thought I would mention the Android version of SB is unrecognizable under Raspberry Pi OS.  :-\

Peter Verhas has a RPi and I have asked him to join us here on the forum and give guidance. My last attempt at this is to try and find the original (fixed for ARM) SB Android source and compile it under RPi. If that doesn't work this becomes an AIR or Peter resolution.
Title: Re: SB Pi
Post by: AIR on March 22, 2019, 01:42:12 PM
Try this. (NOTE: ONLY TESTED THIS ON RAS-PI!)

Edit "make_gcc.jim" and change

Code: [Select]
{#define CcOptCompile=-c -fpic}
to

Code: [Select]
{#define CcOptCompile=-c -fpic -fsigned-char}
Then do "make clean" and then "./setup"

Full credit to Steve Dover for figuring this out when trying to get SB working on Android.


AIR.

Edit:  @John, your myip.sb works on my RasPi now with this tweak.
Title: Re: SB Pi
Post by: John on March 22, 2019, 02:21:16 PM
Thank You!

Peter sent me a message saying he has been away from C and the SB code for too long to be of any help. It looks like you're the main man.  8)
Title: Re: SB Pi
Post by: John on March 22, 2019, 04:04:41 PM
Success!

myip.sb
Code: Script BASIC
  1. IMPORT curl.bas
  2.  
  3. ch = curl::init()
  4. curl::option(ch,"URL","ipinfo.io")
  5. PRINT curl::perform(ch),"\n"
  6. curl::finish(ch)
  7.  


pi@raspberrypi:~/sbrpi/examples $ scriba myip.sb
{
  "ip": "#4.#9.#1.#11",
  "hostname": "c-#4-#9-#1-#11.hsd1.wa.comcast.net",
  "city": "Mount Vernon",
  "region": "Washington",
  "country": "US",
  "loc": "48.4352,-122.2080",
  "postal": "98273",
  "org": "AS33650 Comcast Cable Communications, LLC"
}
pi@raspberrypi:~/sbrpi/examples $

Title: Re: SB Pi
Post by: John on March 22, 2019, 07:37:54 PM
SQLite works.

Code: Script BASIC
  1. IMPORT sqlite.bas
  2.  
  3. db = sqlite::open("sqlite_demo.db")
  4.  
  5. sqlite::execute(db,"create table demo (someval integer, sometxt text);")
  6. sqlite::execute(db,"insert into demo values (123,'hello');")
  7. sqlite::execute(db, "INSERT INTO demo VALUES (234, 'cruel');")
  8. sqlite::execute(db, "INSERT INTO demo VALUES (345, 'world');")
  9.  
  10. stmt = sqlite::query(db,"SELECT * FROM demo")
  11. WHILE sqlite::row(stmt) = sqlite::SQLITE3_ROW
  12.   IF sqlite::fetchhash(stmt, column) THEN
  13.     PRINT column{"someval"},"\t-\t",column{"sometxt"},"\n"
  14.   END IF
  15. WEND
  16.  
  17. sqlite::close(db)
  18.  


pi@raspberrypi:~/sbrpi/examples $ scriba sqlite_demo.sb
123   -   hello
234   -   cruel
345   -   world
pi@raspberrypi:~/sbrpi/examples $


Title: Re: SB Pi
Post by: John on March 22, 2019, 07:52:04 PM
mxml works.

Code: XML
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2.  
  3.  
  4. <stufflist>
  5.         <stuff_test>This is a test!</stuff_test>
  6.         <stuff_test2>And this is another test!</stuff_test2>
  7.         <stuff_test3>
  8.                 <painting>
  9.                         <img src="madonna.jpg" alt='Foligno Madonna, by Raphael'/>
  10.                         <caption>This is Raphael's "Foligno" Madonna, painted in
  11.                                 <date>1511</date>.
  12.                         </caption>
  13.                 </painting>
  14.         </stuff_test3>
  15.         <books>
  16.     <book>
  17.         <id>1</id>
  18.         <name>Hello, world!</name>
  19.     </book>
  20.     <book>
  21.         <id>2</id>
  22.         <name>Hello, China!</name>
  23.     </book>
  24.         </books>
  25. </stufflist>
  26.  

Code: Script BASIC
  1. import mxml.bas
  2.  
  3. filename = "mxml_demo.xml"
  4. doc = mxml::LoadDoc(filename)
  5.  
  6. node =  mxml::GetNode(doc,"/stufflist/stuff_test")
  7. if node then print "Test1: ", mxml::GetNodeValue(node),"\n"
  8.  
  9. node =  mxml::GetNode(doc,"/stufflist/stuff_test2")
  10. if (node) then print "Test2: ", mxml::GetNodeValue(node),"\n\n"
  11.  
  12. node = mxml::GetNode(doc,"/stufflist/stuff_test3/painting/img")
  13. if node then
  14.         print "Image: ", mxml::GetProperty(node,"src"), "\n"
  15.         print "Alt Image: ", mxml::GetProperty(node,"alt"), "\n\n"
  16. endif
  17.  
  18. node = mxml::GetNode(doc,"/stufflist/books")
  19. child = mxml::GetChild(node)
  20.  
  21. while child
  22.         node = mxml::GetNode(child,"id")
  23.         if node then print "ID = ", mxml::GetNodeValue(node),"\n"
  24.         node = mxml::GetNode(child,"name")
  25.         if node then print "Name = ", mxml::GetNodeValue(node),"\n"
  26.        
  27.         child = mxml::GetNext(child)
  28. wend
  29.  
  30. if doc then mxml::FreeDoc(doc)
  31.  


pi@raspberrypi:~/sbrpi/examples $ scriba testmxml.sb
Test1: This is a test!
Test2: And this is another test!

Image: madonna.jpg
Alt Image: Foligno Madonna, by Raphael

ID = 1
Name = Hello, world!
ID = 2
Name = Hello, China!
pi@raspberrypi:~/sbrpi/examples $
Title: Re: SB Pi
Post by: John on March 23, 2019, 07:26:21 AM
My goal today is to get SBT going and test the threaded mode of SB.

Thanks again AIR for keeping your notes over the years as a SB developer. It saved a ton of time getting SB going on the RPi.
Title: Re: SB Pi
Post by: John on March 23, 2019, 09:58:19 AM
AIR,

I was able to compile SBT on the RPi but I'm getting a strange error when loading the extension module.

pi@raspberrypi:~/sbrpi/examples $ scriba -d hellomain.sb
Searching installed module header file 'sbt.bas' ...
Checking installed module header file location '/home/pi/sbrpi/include/sbt.bas' Result=OK
Including file '/home/pi/sbrpi/include/sbt.bas'
dlopen failed.
dlerror message=/home/pi/sbrpi/modules/sbt.so: undefined symbol: ulGlobalVariables
(0): error &H10:The requested module can not be loaded.
pi@raspberrypi:~/sbrpi/examples $


Attached is my SBT source directory.

If I do a nm on sbt.so it looks like the ulGlobalVariables is there.


0004e178 t TruncatedLength
         U ulGlobalVariables
         U ulNodeCounter
         U ulStartNode
         U ulStringTableSize
00098314 D UNARIES
Title: Re: SB Pi
Post by: AIR on March 23, 2019, 01:00:01 PM

If I do a nm on sbt.so it looks like the ulGlobalVariables is there.


0004e178 t TruncatedLength
         U ulGlobalVariables
         U ulNodeCounter
         U ulStartNode
         U ulStringTableSize
00098314 D UNARIES


"U" here means that there is a reference to those items, but they are accessed at runtime.  Similar to accessing functions from libc.  Are you maybe missing a file, or perhaps those items are not exported?
Title: Re: SB Pi
Post by: John on March 23, 2019, 01:04:23 PM
 Can you take a peek at my makefile.pi? Maybe how I'm linking doesn't work on RPi.
Title: Re: SB Pi
Post by: AIR on March 23, 2019, 01:32:07 PM
You're linking libscriba, but ldd on your sbt.so doesn't show it.  Where do you have it installed?

I stripped out everything except the cbasic.h file, the interface.c file, and the sbt.bas file.

Then I did:  ./setup --module=sbt (after copying the sbt folder over to the extensions folder).

Now on my Pi, ldd shows:

riveraa@rpi:~/src/sb-dev/bin/mod/dll $ ldd sbt.so
   linux-vdso.so.1 (0x7ec8b000)
   /usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f04000)
   libscriba.so => /usr/local/lib/libscriba.so (0x76e56000)
   libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76e2d000)
   libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76dae000)
   libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76c6f000)
   libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76c5c000)
   /lib/ld-linux-armhf.so.3 (0x76f2e000)


I have libscriba.so in /usr/local/lib.  I had to do: sudo ldconfig before the system recognized it was there.

AIR.
Title: Re: SB Pi
Post by: John on March 23, 2019, 04:13:25 PM
My bad.

I forgot to copy libscriba.so to the /usr/lib directory and only copied libscriba.a there to get it to compile. I'll do another recompile and ldconf before the build. Thanks for getting me back on the right path.
Title: Re: SB Pi
Post by: John on March 23, 2019, 04:42:30 PM
You're the man!

hellomain
Code: Script BASIC
  1. IMPORT sbt.bas
  2.  
  3. sb = SB_New()
  4.  
  5. SB_Configure sb, "/etc/scriba/basic.conf"
  6. SB_Load sb, "hellothread.sb"
  7. SB_Run sb, ""
  8. funcrtn = SB_CallSubArgs(sb,"main::pthello")
  9. PRINT funcrtn,"\n"
  10.  
  11. PRINT SB_GetVar(sb, "main::a"),"\n"
  12.  
  13. SB_Destroy sb
  14.  

hellothread
Code: Script BASIC
  1. FUNCTION pthello
  2.   PRINT "Hello Thread\n"
  3.   pthello = 1
  4. END FUNCTION
  5.  
  6. a = "SBT"
  7.  


pi@raspberrypi:~/sbrpi/examples $ scriba hellomain.sb
Hello Thread
1
SBT
pi@raspberrypi:~/sbrpi/examples $


I still need to do more testing but I think it's working.  :)
Title: Re: SB Pi
Post by: AIR on March 23, 2019, 06:26:58 PM
New RasPi appimage attached as you requested, John.

Note:  I don't know if SBT will work if you remove libscriba.so from your library path.

AIR.
Title: Re: SB Pi
Post by: John on March 23, 2019, 06:35:05 PM
Thanks !!!

I'll give it a try.

Here is the asynchronous thread example working. It seems task switching on the RPi isn't as robust as my Ubuntu box.

Code: Script BASIC
  1. ' SBT Main
  2.  
  3. IMPORT sbt.bas
  4.  
  5. SB_ThreadStart("sbt_thread.sb", "1","/etc/scriba/basic.conf")
  6. SB_ThreadStart("sbt_thread.sb", "2","/etc/scriba/basic.conf")
  7. SB_ThreadStart("sbt_thread.sb", "3","/etc/scriba/basic.conf")
  8.  
  9. FOR x = 1 TO 10
  10.   PRINT "Main: ",x,"\n"
  11.   sb_msSleep(150)
  12. NEXT
  13.  
  14. SLEEP(2)
  15.  

Code: Script BASIC
  1. ' SBT Thread
  2.  
  3. IMPORT sbt.bas
  4.  
  5. tnum = COMMAND()
  6.  
  7. FOR x = 1 TO 10
  8.   PRINT "T-" & tnum," : ",x,"\n"
  9.   SB_msSleep(150)
  10. NEXT
  11.  
  12. SB_ThreadEnd
  13.  


pi@raspberrypi:~/sbrpi/examples $ scriba sbt_main.sb
Main: 1
Main: 2
Main: 3
Main: 4
Main: 5
Main: 6
Main: 7
Main: 8
Main: 9
Main: 10
T-1 : 1
T-1 : 2
T-2 : 1
T-1 : 3
T-1 : 4
T-2 : 2
T-1 : 5
T-2 : 3
T-1 : 6
T-2 : 4
T-1 : 7
T-2 : 5
T-1 : 8
T-3 : 1
T-2 : 6
T-1 : 9
T-2 : 7
T-1 : 10
T-3 : 2
T-2 : 8
T-3 : 3
T-2 : 9
T-3 : 4
T-2 : 10
T-3 : 5
T-3 : 6
T-3 : 7
T-3 : 8
T-3 : 9
T-3 : 10
pi@raspberrypi:~/sbrpi/examples $

Title: Re: SB Pi
Post by: AIR on March 23, 2019, 06:38:11 PM
The AppImage is going to need a custom build of SBT, I think.  It doesn't currently work if libscriba.so is not in the system library path.  I just tested.

AIR.
Title: Re: SB Pi
Post by: John on March 23, 2019, 06:43:39 PM
Quote
It doesn't currently work if libscriba.so is not in the system library path.

system library path = /usr/lib ?

That is where my libscriba lives.
Title: Re: SB Pi
Post by: AIR on March 23, 2019, 06:45:53 PM
Whatever is configured in the ld cache;  for example, I have /usr/local/lib in mine which is where I place libraries that I build.

I'm researching how to resolve libs that are inside the app image.  stay tuned...
Title: Re: SB Pi
Post by: AIR on March 23, 2019, 07:03:15 PM
Tweaked the environment within the AppImage:

riveraa@rpi:~/Projects/sb $ sb hellomain.sb
Hello Thread
1
SBT


Updated AppImage attached.
Title: Re: SB Pi
Post by: John on March 23, 2019, 07:40:58 PM
Sweet!

I'll give it a good test with the extension modules as well.

What is cool about the Raspberry Pi is we are all working with the same hardware and it's cheap enough curiosity can afford it.
Title: Re: SB Pi
Post by: John on March 23, 2019, 10:28:21 PM
It seems the sqlite.bas include can't be found with the AppImage.

Code: [Select]
pi@raspberrypi:~/Downloads $ sb --appimage-extract
squashfs-root/.DirIcon
squashfs-root/AppRun
squashfs-root/required-libs.txt
squashfs-root/sb.desktop
squashfs-root/sb.png
squashfs-root/sb.sh
squashfs-root/usr
squashfs-root/usr/bin
squashfs-root/usr/bin/sb
squashfs-root/usr/bin/sbhttpd
squashfs-root/usr/bin/scriba
squashfs-root/usr/include
squashfs-root/usr/include/cgi.bas
squashfs-root/usr/include/curl.bas
squashfs-root/usr/include/curses.bas
squashfs-root/usr/include/dbg.bas
squashfs-root/usr/include/dyc.bas
squashfs-root/usr/include/ftpd.bas
squashfs-root/usr/include/hash.bas
squashfs-root/usr/include/json.bas
squashfs-root/usr/include/mt.bas
squashfs-root/usr/include/mxml.bas
squashfs-root/usr/include/mysql.bas
squashfs-root/usr/include/nt.bas
squashfs-root/usr/include/odbc.bas
squashfs-root/usr/include/sbt.bas
squashfs-root/usr/include/sdbg.bas
squashfs-root/usr/include/slre.bas
squashfs-root/usr/include/sqlite.bas
squashfs-root/usr/include/t.bas
squashfs-root/usr/include/trial.bas
squashfs-root/usr/include/ux.bas
squashfs-root/usr/include/zlib.bas
squashfs-root/usr/lib
squashfs-root/usr/lib/libscriba.a
squashfs-root/usr/lib/libscriba.so
squashfs-root/usr/lib/lscriba.a
squashfs-root/usr/module
squashfs-root/usr/module/cgi.so
squashfs-root/usr/module/curl.so
squashfs-root/usr/module/curses.so
squashfs-root/usr/module/dbg.so
squashfs-root/usr/module/hash.so
squashfs-root/usr/module/json.so
squashfs-root/usr/module/mt.so
squashfs-root/usr/module/mxml.so
squashfs-root/usr/module/mysql.so
squashfs-root/usr/module/odbc.so
squashfs-root/usr/module/sbt.so
squashfs-root/usr/module/sdbg.so
squashfs-root/usr/module/slre.so
squashfs-root/usr/module/sqlite.so
squashfs-root/usr/module/t.so
squashfs-root/usr/module/trial.so
squashfs-root/usr/module/ux.so
squashfs-root/usr/module/zlib.so
pi@raspberrypi:~/Downloads $

It's in there but my test script that worked with the system install of SB works.

pi@raspberrypi:~/sbrpi/examples $ scriba -d sqlite_demo.sb
Searching installed module header file 'sqlite.bas' ...
sqlite_demo.sb(1): error &H3e:Include file is not found
pi@raspberrypi:~/sbrpi/examples $
Title: Re: SB Pi
Post by: AIR on March 23, 2019, 10:33:39 PM
Works fine here.

riveraa@rpi:~/Projects/sb $ sb sqlitedemo.sb
123 - hello
234 - cruel
345 - world
SQLite Version: 3.16.2


AIR.
Title: Re: SB Pi
Post by: John on March 23, 2019, 10:40:00 PM
Even using a direct path to the sqlite.bas fails to load.

Code: Script BASIC
  1. ' IMPORT sqlite.bas
  2. INCLUDE "/home/pi/sbrpi/include/sqlite.bas"
  3.  
  4. db = sqlite::open("sqlite_demo.db")
  5.  
  6. sqlite::execute(db,"create table demo (someval integer, sometxt text);")
  7. sqlite::execute(db,"insert into demo values (123,'hello');")
  8. sqlite::execute(db, "INSERT INTO demo VALUES (234, 'cruel');")
  9. sqlite::execute(db, "INSERT INTO demo VALUES (345, 'world');")
  10.  
  11. stmt = sqlite::query(db,"SELECT * FROM demo")
  12. WHILE sqlite::row(stmt) = sqlite::SQLITE3_ROW
  13.   IF sqlite::fetchhash(stmt, column) THEN
  14.     PRINT column{"someval"},"\t-\t",column{"sometxt"},"\n"
  15.   END IF
  16. WEND
  17.  
  18. sqlite::close(db)
  19.  

pi@raspberrypi:~/sbrpi/examples $ scriba -d sqlite_demo.sb
Including file '/home/pi/sbrpi/include/sqlite.bas'
(0): error &H10:The requested module can not be loaded.
pi@raspberrypi:~/sbrpi/examples $

This works.

pi@raspberrypi:~/sbrpi/examples $ scriba -f/etc/scriba/basic.conf.system sqlite_demo.sb
123   -   hello
234   -   cruel
345   -   world
pi@raspberrypi:~/sbrpi/examples $
Title: Re: SB Pi
Post by: AIR on March 23, 2019, 10:44:44 PM
The appimage is called "sb" not "scriba".

what's the output with the "-D" switch?
Title: Re: SB Pi
Post by: John on March 23, 2019, 10:47:55 PM
It works if I use SB instead of scriba which I have renamed the /etc/scriba/basic.conf.system.

Sorry!


pi@raspberrypi:~/sbrpi/examples $ time sb sqlite_demo.sb
123   -   hello
234   -   cruel
345   -   world

real   0m0.213s
user   0m0.085s
sys   0m0.043s
pi@raspberrypi:~/sbrpi/examples $


Title: Re: SB Pi
Post by: John on March 24, 2019, 08:51:02 AM
AIR,

What are the steps to rebuild the SB AppImage from a --appimage-extract?

It would be great to create a new sandbox repo for the Raspberry Pi. The source would only include the files needed to build the core interpreter components and extension modules that make sense for the RPi. There is a lot of test and deprecated code taking a ride in the source tree.

I'm going to start working on a User Guide PDF we can include with the AppImage distribution.

I wish Joe (Big Fish) from the BaCon forum would join us as he has a RPi interest and is great at documention.

My mission for 2019 is to make Script BASIC the language of choice on the Raspberry Pi and included in the distribution.

The RPi reminds me of the good old days of Heathkit.
Title: Re: SB Pi
Post by: AIR on March 24, 2019, 10:57:07 AM
You need appimagetool-armhf (https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-armhf.AppImage)
Title: Re: SB Pi
Post by: John on March 24, 2019, 11:07:21 AM
I was able to get the mysql extension module working. Getting MySQL and phpmyadin working took some research. It seems root@localhost only works with root privileges. This is what I had to do to get phpmyadmin running.

To get Apache to see phpmyadmin, you need to do the following.

sudo ln -s /usr/share/phpmyadmin /var/www/html
sudo mysql -u root

Code: MySQL
  1. MariaDB [(none)]> CREATE USER 'Rpi'@'localhost' IDENTIFIED BY 'Rpi-PW';
  2. MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'Rpi'@'localhost';
  3. MariaDB [(none)]> FLUSH PRIVILEGES;
  4. quit
  5.  

sudo service mysql restart

Code: Script BASIC
  1. ' MySQL Test Program
  2.  
  3. INCLUDE mysql.bas
  4.  
  5. dbh = mysql::RealConnect("localhost","Rpi","Rpi-PW","classicmodels")
  6.  
  7. mysql::query(dbh,"SELECT * FROM products WHERE productLine = 'Planes'")
  8.  
  9. WHILE mysql::FetchHash(dbh,column)
  10.   PRINT column{"productCode"}," - ",column{"productName"},"\n"
  11. WEND
  12.  
  13. PRINTNL
  14. PRINT "The database handle is: ",dbh,"\n"
  15. PRINT "Affected rows by SELECT: ",mysql::AffectedRows(dbh),"\n"
  16. PRINT "Character set name is: ",mysql::CharacterSetName(dbh),"\n"
  17. PRINT "Last error is: ",mysql::ErrorMessage(dbh),"\n"
  18. PRINT "Client info is: ",mysql::GetClientInfo(),"\n"
  19. PRINT "Host info is: ",mysql::GetHostInfo(dbh),"\n"
  20. PRINT "Proto info is: ",mysql::GetProtoInfo(dbh),"\n"
  21. PRINT "Server info is: ",mysql::GetServerInfo(dbh),"\n"
  22. PRINT "PING result: ",mysql::Ping(dbh),"\n"
  23. PRINT "Thread ID: ",mysql::ThreadId(dbh),"\n"
  24. PRINT "Status is: ",mysql::Stat(dbh),"\n"
  25.  
  26. mysql::Close(dbh)
  27.  


pi@raspberrypi:~/sbrpi/examples $ sb testmysql.sb
S18_1662 - 1980s Black Hawk Helicopter
S18_2581 - P-51-D Mustang
S24_1785 - 1928 British Royal Navy Airplane
S24_2841 - 1900s Vintage Bi-Plane
S24_3949 - Corsair F4U ( Bird Cage)
S24_4278 - 1900s Vintage Tri-Plane
S700_1691 - American Airlines: B767-300
S700_2466 - America West Airlines B757-200
S700_2834 - ATA: B757-300
S700_3167 - F/A 18 Hornet 1/72
S700_4002 - American Airlines: MD-11S
S72_1253 - Boeing X-32A JSF

The database handle is: 1
Affected rows by SELECT: 12
Character set name is: latin1
Last error is:
Client info is: 10.1.37-MariaDB
Host info is: Localhost via UNIX socket
Proto info is: 10
Server info is: 10.1.37-MariaDB-0+deb9u1
PING result: -1
Thread ID: 0
Status is: Uptime: 1224  Threads: 1  Questions: 490  Slow queries: 0  Opens: 29  Flush tables: 1  Open tables: 23  Queries per second avg: 0.400
pi@raspberrypi:~/sbrpi/examples $ ^C


I've attached the DB (classicmodels) in a SQL DUMP to use the above example.

Title: Re: SB Pi
Post by: John on March 24, 2019, 11:28:49 AM
AIR,

Can you post an example for your JSON and RE extension modules?
Title: Re: SB Pi
Post by: AIR on March 24, 2019, 11:42:53 AM
https://www.allbasic.info/forum/index.php?topic=531.msg5874#msg5874 json
https://www.allbasic.info/forum/index.php?topic=524.msg5700#msg5700 slre
Title: Re: SB Pi
Post by: John on March 24, 2019, 11:51:44 AM
My next task is showing sbhttpd running as an application proxy server under Apache on the RPi.

I don't think I can use the AppImage for this and will have to use my system install unless AIR can tell me how to use sbhttpd from the AppImage.
Title: Re: SB Pi
Post by: John on March 24, 2019, 05:10:30 PM
I was able to get the sbhttpd application proxy server going on RPi. I think this is out side the scope of the sb AppImage.

1. The first step is enable the Apache modules you will need.

pi@raspberrypi:~/sbrpi/examples $ sudo a2enmod
Your choices are: access_compat actions alias allowmethods asis auth_basic auth_digest auth_form authn_anon authn_core authn_dbd authn_dbm authn_file authn_socache authnz_fcgi authnz_ldap authz_core authz_dbd authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex buffer cache cache_disk cache_socache cern_meta cgi cgid charset_lite data dav dav_fs dav_lock dbd deflate dialup dir dump_io echo env expires ext_filter file_cache filter headers heartbeat heartmonitor http2 ident imagemap include info lbmethod_bybusyness lbmethod_byrequests lbmethod_bytraffic lbmethod_heartbeat ldap log_debug log_forensic lua macro mime mime_magic mpm_event mpm_prefork mpm_worker negotiation php7.0 proxy proxy_ajp proxy_balancer proxy_connect proxy_express proxy_fcgi proxy_fdpass proxy_ftp proxy_hcheck proxy_html proxy_http proxy_http2 proxy_scgi proxy_wstunnel ratelimit reflector remoteip reqtimeout request rewrite sed session session_cookie session_crypto session_dbd setenvif slotmem_plain slotmem_shm socache_dbm socache_memcache socache_shmcb speling ssl status substitute suexec unique_id userdir usertrack vhost_alias xml2enc
Which module(s) do you want to enable (wildcards ok)?
proxy proxy_connect proxy_html proxy_http rewrite
Enabling module proxy.
Considering dependency proxy for proxy_connect:
Module proxy already enabled
Enabling module proxy_connect.
Considering dependency proxy for proxy_html:
Module proxy already enabled
Considering dependency xml2enc for proxy_html:
Enabling module xml2enc.
Enabling module proxy_html.
Considering dependency proxy for proxy_http:
Module proxy already enabled
Enabling module proxy_http.
Enabling module rewrite.
To activate the new configuration, you need to run:
  systemctl restart apache2
pi@raspberrypi:~/sbrpi/examples $ sudo systemctl restart apache2

2. Next is adding the Proxy/PoxyRewrite commands to the Apache default configuration file.

sudo vi  /etc/apache2/sites-enabled/000-default.conf

add these lines.

ProxyPass /home http://localhost:8181/
ProxyPassReverse /home http://localhost:8181/

3. Extend the default basic.conf file to include the following.

pi@raspberrypi:/etc/scriba $ scriba -D
dll ".so"
module "/home/pi/sbrpi/modules/"
include "/home/pi/sbrpi/include/"
maxstep 0
maxlocalstep 0
maxlevel 35611
maxmem 0
servers (
  server (
    port 8181
    ip "127.0.0.1"
    protocol "http"
   )
  threads 1000
  listenbacklog 5
  home "/home/pi/sbrpi/web/"
  proxyip 1
  pid (
    file "/home/pi/sbrpi/log/pid.txt"
    delay 10
    wait (
      period 10
      length 1
     )
   )
  vdirs (
    dir "/home/test/:/home/pi/sbrpi/web/test/"
   )
  errmsgdest 3
  nolog 0
  log (
    panic (
      file "/home/pi/sbrpi/log/panic.log"
     )
    app (
      file "/home/pi/sbrpi/log/app.log"
     )
    err (
      file "/home/pi/sbrpi/log/err.log"
     )
    hit (
      file "/home/pi/sbrpi/log/hit.log"
     )
    stat (
      file "/home/pi/sbrpi/log/stat.log"
     )
   )
  msg404 """
  <HTML>
  <HEAD>
  <TITLE>Error 404 page not found</TITLE>
  </HEAD>
  <BODY>
  <FONT FACE=\"Verdana\" SIZE=\"2\">
  <H1>Page not found</H1>
  The page you have requested can not be found on this server.
  <p>
  If you feel this is a server misconfiguration, please contact:
  <FONT SIZE=\"3\"><TT>support@scriptbasic.org</TT></FONT>
  </FONT>
  </BODY>
  </HTML>
  """
  code404 "200 OK"
 )
pi@raspberrypi:/etc/scriba $

4. Add the directories and files specified in the above basic.conf.txt file.

/home/pi/sbrpi/web
/home/pi/sbrpi/web/test
/home/pi/sbrpi/log

Creating these empty files with touch is the best way.

/home/pi/sbrpi/log/app.log
/home/pi/sbrpi/log/err.log
/home/pi/sbrpi/log/hit.log
/home/pi/sbrpi/log/panic.log
/home/pi/sbrpi/log/pid.txt
/home/pi/sbrpi/logstat.log

5. Create the echo SB script in the /home/pi/sbrpi/web directory.

Code: Script BASIC
  1. ' CGI Echo
  2.  
  3. GLOBAL CONST nl = "\n"
  4. CONST NumberOfCookies = 3
  5.  
  6. INCLUDE cgi.bas
  7.  
  8. OPTION cgi$Method cgi::Get OR cgi::Post
  9.  
  10. cgi::Header 200,"text/html"
  11.  
  12. FOR i = 1 TO NumberOfCookies
  13.   ' cookie(i) is i, no domain is defined, path is /, expires after 10 seconds, not secure
  14.  cgi::SetCookie "cookie" & i, i, undef, "/", gmtime() + 10, false
  15. NEXT
  16.  
  17. cgi::FinishHeader
  18.  
  19. '-------------------------------------------------------
  20. PRINT """
  21. <HTML>
  22. <HEAD>
  23. <title>CGI Echo</title>
  24. </HEAD>
  25. <BODY><font face="VERDANA" size="2">
  26. <H1>View CGI Parameters</H1>
  27. This page shows the CGI parameters the way it was uploaded.
  28. <!-- here is the result of the previous HTTP request -->
  29. <FONT SIZE="3">
  30. <PRE>
  31. CGI system variables
  32. --------------------
  33.  
  34. """
  35.  
  36. PRINT "ServerSoftware  = ", cgi::ServerSoftware(), nl
  37. PRINT "ServerName      = ", cgi::ServerName(), nl
  38. PRINT "GatewayInterface= ", cgi::GatewayInterface(),nl
  39. PRINT "ServerProtocol  = ", cgi::ServerProtocol(), nl
  40. PRINT "ServerPort      = ", cgi::ServerPort(), nl
  41. PRINT "RequestMethod   = ", cgi::RequestMethod(), nl
  42. PRINT "PathInfo        = ", cgi::PathInfo(), nl
  43. PRINT "PathTranslated  = ", cgi::PathTranslated(), nl
  44. PRINT "ScriptName      = ", cgi::ScriptName(), nl
  45. PRINT "QueryString     = ", cgi::QueryString(), nl
  46. PRINT "RemoteHost      = ", cgi::RemoteHost(), nl
  47. PRINT "RemoteAddress   = ", cgi::RemoteAddress(), nl
  48. PRINT "AuthType        = ", cgi::AuthType(), nl
  49. PRINT "RemoteUser      = ", cgi::RemoteUser(), nl
  50. PRINT "RemoteIdent     = ", cgi::RemoteIdent(), nl
  51. PRINT "ContentType     = ", cgi::ContentType(), nl
  52. PRINT "ContentLength   = ", cgi::ContentLength(), nl
  53. PRINT "UserAgent       = ", cgi::UserAgent(), nl
  54. PRINT "Cookie          = ", cgi::RawCookie(), nl
  55.  
  56. PRINT "Referer         = ", cgi::Referer(), nl
  57. PRINT "Password        = ", Environ("HTTP_PASSWORD"), nl
  58. PRINT "Full auth string= ", Environ("HTTP_AUTHORIZATION"), nl
  59. PRINT "\nCookies:\n"
  60. FOR i = 1 TO NumberOfCookies
  61.   PRINT "cookie" & i, " ", cgi::Cookie("cookie" & i), "\n"
  62. NEXT
  63.  
  64. IF cgi::RequestMethod() = "GET" THEN
  65.   PRINT "GET text field using GetParam(\"TEXT-GET\") is ", cgi::GetParam("TEXT-GET"), nl
  66. END IF
  67.  
  68. IF cgi::RequestMethod() = "POST" THEN
  69.   PRINT "POST text field using PostParam(\"TEXT-POST\") is ", cgi::PostParam("TEXT-POST"), nl
  70. END IF
  71.  
  72. PRINT """
  73. </PRE>
  74. <TABLE>
  75.  <TR>
  76.    <TD BORDER=0 BGCOLOR="EEEEEE">
  77.      <PRE>
  78.      A simple form to POST parameters:<BR>
  79.      <FORM METHOD="POST" ACTION="/home/echo">
  80.        <INPUT TYPE="TEXT" VALUE="Default POST Field Text" NAME="TEXT-POST">
  81.        <INPUT TYPE="SUBMIT" NAME="SUBMIT-BUTTON" VALUE=" POST ">
  82.      </FORM>
  83.      </PRE>
  84.    </TD>
  85.    <TD BORDER=1 width="20">&nbsp;</TD>
  86.    <TD BORDER=0 BGCOLOR="EEEEEE">
  87.    <PRE>
  88.    A simple form to GET parameters:<BR>
  89.    <FORM METHOD="GET" ACTION="/home/echo">
  90.      <INPUT TYPE="TEXT" VALUE="Default GET Field Text" NAME="TEXT-GET">
  91.      <INPUT TYPE="SUBMIT" NAME="SUBMIT-BUTTON" VALUE=" GET ">
  92.    </FORM>
  93.  
  94.    </TD>
  95.  </TR>
  96. </TABLE>
  97. </BODY>
  98. </HTML>
  99. """


6. Start the Script BASIC proxy server as a service.

sudo sbhttpd -start


7. Use localhost/home/echo as the web browser URL.


(https://allbasic.info/picture_library/sbhttpd_echo.png)







Title: Re: SB Pi
Post by: John on March 25, 2019, 01:34:53 PM
I picked up a fast 128 GB micro memory card for the Raspberry Pi. I'll let you all know if it works with the RPi.

Update

I had to install a special FAT32 format utility to format my new 128 GB SD card before copying the NOOBS files to it.. On a positive note downloading / installing NOOBS from scratch installed a full version of the OS rather than the bare bones version pre-installed on the 32 GB SD that came with the Raspberry Pi. I'm seeing 9 MB per second write and 17 MB per second read speed.  :)


pi@raspberrypi:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       116G  5.0G  105G   5% /
devtmpfs        460M     0  460M   0% /dev
tmpfs           464M     0  464M   0% /dev/shm
tmpfs           464M  6.3M  458M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           464M     0  464M   0% /sys/fs/cgroup
/dev/mmcblk0p6   68M   22M   47M  33% /boot
tmpfs            93M     0   93M   0% /run/user/1000
/dev/mmcblk0p5   30M  398K   28M   2% /media/pi/SETTINGS
pi@raspberrypi:~ $
Title: Re: SB Pi
Post by: AIR on March 25, 2019, 04:49:58 PM
Quick tip for installing the required dev libraries to build the SB modules.

Create a file called "requirements_raspi.txt" with the following content:
libcurl4-gnutls-dev
libiodbc2-dev
libmariadbclient-dev-compat
libncurses5-dev
libsqlite3-dev
libssl-dev


Then you can do:
sudo apt install  $(awk '{print $1'} requirements_raspi.txt)

AIR.
Title: Re: SB Pi
Post by: John on March 25, 2019, 05:33:16 PM
Thanks AIR!

One bad thing about using a USB memory stick is it doesn't save permission / mode. (RWE).
Title: Re: SB Pi
Post by: AIR on March 25, 2019, 05:52:41 PM
Quote from: commits
Added support for creating AppImage files 7a75a42f

Added RasberryPi requirements for Module Development 52165ceb

Added -fsigned-char to compile options 166b624b

NOTES:

The tool "appimagetool" must be in your path in order for the mkappimage.sh script to work.

Under Linux i386/x64, C defaults to using signed char for chars/strings, under Linux ARM we need to tell the compiler to use signed chars when compiling SB.

AIR.
Title: Re: SB Pi
Post by: AIR on March 25, 2019, 05:58:21 PM
Thanks AIR!

One bad thing about using a USB memory stick is it doesn't save permission / mode. (RWE).

That would depend on the format you're using.  If using Fat32/exFat, then yeah, you'll have that problem.
Title: Re: SB Pi
Post by: John on March 25, 2019, 07:21:13 PM
I should have zipped the files and they would have retained file attributes.
Title: Re: SB Pi
Post by: AIR on March 25, 2019, 07:24:22 PM
I avoid this by using scp to copy files from one system to another.
Title: Re: SB Pi
Post by: John on March 25, 2019, 08:01:37 PM
Actually my Samba network works well with both Windows and the RPi. My Ubuntu box runs Samba and is connected to the Comcast router via a ethernet cable. The Win10 laptop and RPi connect via WIFI.

I wish Tomaaz was around to create a Script BASIC Geany syntax hightlighting file.  :(
Title: Re: SB Pi
Post by: John on March 25, 2019, 10:22:19 PM
I finally back to where I was on the old 32 GB SD card.

@AIR - I downloaded the most recent SB-DEV rather than try and fix my file attribute issues copying the files to a standard USB memory stick.

Thanks for the AppImage build script!
Title: Re: SB Pi
Post by: AIR on March 25, 2019, 10:40:16 PM
You could "git clone" it if you add the 8181 port to the clone command (via https):

git clone https://sandbox.allbasic.info:8181/scriptbasic/sb-dev.git

Before working on the appimage script, I installed DietPi (instead of Raspbian) on a spare sd card.

I had to disable things like their login banner/script, because I hate banners and also because it was causing Midnight Commander issues with my logon id (I never use the defaults provided by the distro, I always create my own logon with sudo access).

Then I cloned the repository directly onto the RasPi, added the script/made changes, and then pushed back up.

I run my Pi's headless, so no gui/keyboard/monitor attached.  Just good old ssh.

AIR.
Title: Re: SB Pi
Post by: John on March 25, 2019, 10:50:50 PM
Cool!

My next task is to create a SB-RELEASE repo with only the files being used. I'm also going to remove the Ubuntu build directory from SB-DEV.
Title: Re: SB Pi
Post by: John on March 25, 2019, 11:03:31 PM
AIR,

Can you push your cleaned up copy of SBT to the sandbox?
Title: Re: SB Pi
Post by: AIR on March 25, 2019, 11:17:34 PM
Quote from: COMMIT
Added John's SBT module d2b91261

Remember, in order to compile this, libscriba.so must be in your library path.

Title: Re: SB Pi
Post by: John on March 25, 2019, 11:19:41 PM
Thanks AIR!
Title: Re: SB Pi
Post by: John on March 26, 2019, 12:40:21 AM
With SBT's ability to run threads from code strings dynamically at runtime, an AI paradigm could be scripted. As icing SB supports a cascading pre-processor. (the output of one pre-proccor can be the input to the next)



Title: Re: SB Pi
Post by: John on March 26, 2019, 09:45:50 AM
I'm happy how well sbhttpd runs on the RPi. This will give the GPIO API a web browser interface. The security features built into sbhttpd make it an ideal interface.
Title: Re: SB Pi
Post by: John on March 26, 2019, 12:26:42 PM
The Raspberry Pi Script BASIC project lead by AIR and myself needs your help to make SB the language of choice on the RPi. This is a chance to get SB in front of a lot of users with a device of common ground.

If you have time to contribute and help others learn computing / programming please join us and help the project out.
Title: Re: SB Pi
Post by: John on March 27, 2019, 12:39:57 PM
AIR,

I was thinking of using your gcc make file for Windows as a guide to build the SB-RELEASE sandbox repo. Do you know of a better way?

Title: Re: SB Pi
Post by: AIR on March 27, 2019, 05:23:09 PM
I don't understand what it is you're trying to accomplish.

With a repository (git or other VCS), typically the MASTER branch is your release branch, with other branches used for development/alternatives.  That's the proper way to manage a project from version control perspective.

AIR.
Title: Re: SB Pi
Post by: John on March 27, 2019, 05:33:10 PM
There is a ton of stuff in the SB-DEV repo that isn't referenced or needed to build a SB runtime. I want to have a repo with only relevant code for general distribution on any platform,
Title: Re: SB Pi
Post by: AIR on March 27, 2019, 05:47:18 PM
Thatís where branches come in.

Create one, switch to it, and start your cleanup. And make use of the .gitignore file to keep it that way.

If you find that youíve removed something thatís needed, you can always revert to a previous commit.

AIR.
Title: Re: SB Pi
Post by: John on March 27, 2019, 05:59:17 PM
That seems like the way to go Unfornately I don't have but basic git skills. Would you have time to make the SB-DEV repo right?
Title: Re: SB Pi
Post by: John on March 27, 2019, 08:40:40 PM
Using sbhttpd as a user interface is it handles proper thread task switching without the developer having to be involved at that level. (like a real web server) Icing it runs as service.
Title: Re: SB Pi
Post by: AIR on March 27, 2019, 10:41:18 PM
I've created a new branch called "cleanup".  I removed a bunch of cruft.

Do Not Indiscriminately Push Anything To This Branch.

I don't know how it will compile in Windows.  It works in Linux and RasPi.

There are a few more things that can be cleaned up...mostly Windows CMD scripts.

Rather than create separate repositories for each OS, create BRANCHES if you need to.  For example, a separate WINDOWS branch.

IMPORTANT:  DO NOT MERGE BACK TO THE MAIN BRANCH YET!!!

John, you are going to have to become more familiar with git.  There's no way around that. 

Use this cheatsheet (https://education.github.com/git-cheat-sheet-education.pdf) for starters. 

GIT is really simple to use; most GUI clients for it are just fancy front ends.

AIR.
Title: Re: SB Pi
Post by: AIR on March 28, 2019, 12:03:53 AM
Played around with packaging this up for RasPi.

Here's the output of dpkg --list scriptbasic after I installed the deb package I created:

||/ Name                      Version           Architecture      Description
+++-=========================-=================-=================-=======================================================
ii  scriptbasic               2.1-1             armhf             Basic Interpreter


Debian Package for RasPi is attached.

Install with:
Code: [Select]
dpkg -i scriptbasic-2.1-armf.deb
Uninstall with:
Code: [Select]
dpkg --remove scriptbasic
Important Note

If you already have SB installed, if you use the remove command to uninstall the package it will probably mess up any manual install.  The SB appimage is not affected by this.

AIR.
Title: Re: SB Pi
Post by: John on March 28, 2019, 07:27:35 AM
That's great AIR!

I won't touch the repo until you're done with your house cleaning efforts.

It's pretty easy to uninstall my system install of SB. I just need rename /etc/scriba/basic.conf and /usr/bin/scriba. My include and modules directories live in my home directory.
Title: Re: SB Pi
Post by: John on March 28, 2019, 12:26:26 PM
I tried your SB RPi install and it seemed to work for console based scripts. The uninstall seemed to work as well.

I have to use my system install due to the extra needs of sbhttpd.

Another nice security feature of sbhttpd is that the script code your running isn't in the web root. You can't hack what you can't see.  8)
Title: Re: SB Pi
Post by: AIR on March 28, 2019, 02:13:52 PM
It should work if you update the /etc/scriba/basic.conf that this uses, or if you pass a custom conf file.

Thanks for testing, this was generated using the CLEANUP branch.

AIR.
Title: Re: SB Pi
Post by: John on March 28, 2019, 03:08:11 PM
I totally forgot that you added the -f option to sbhttpd.
Title: Re: SB Pi
Post by: John on March 28, 2019, 04:17:22 PM
AIR,

I reinstalled your DEB install and started going through my examples. It seems there is path problem with where modules are installed.


pi@raspberrypi:~/sbrpi/examples $ scriba myip.sb
(0): error &H10:The requested module can not be loaded.
pi@raspberrypi:~/sbrpi/examples $ scriba -d myip.sb
Searching installed module header file 'curl.bas' ...
Checking installed module header file location '/usr/local/include/scriba/curl.bas' Result=OK
Including file '/usr/local/include/scriba/curl.bas'
dlopen failed.
dlerror message=/usr/local/lib/curl.so: cannot open shared object file: No such file or directory
(0): error &H10:The requested module can not be loaded.
pi@raspberrypi:~/sbrpi/examples $ ls -l /usr/local/lib/
total 2236
-rw-r--r-- 1 1001  1001 789970 Mar 27 22:49 libscriba.a
-rwxr-xr-x 1 1001  1001 694768 Mar 27 22:49 libscriba.so
-rw-r--r-- 1 1001  1001 786690 Mar 27 22:49 lscriba.a
drwxrwsr-x 3 root staff   4096 Nov 13 05:40 pypy2.7
drwxrwsr-x 4 root staff   4096 Nov 13 05:20 python2.7
drwxrwsr-x 3 root staff   4096 Nov 13 05:12 python3.5
pi@raspberrypi:~/sbrpi/examples $ scriba -D
dll ".so"
module "/usr/local/lib/"
include "/usr/local/include/scriba/"
maxstep 0
maxlocalstep 0
maxlevel 29666
maxmem 0
pi@raspberrypi:~/sbrpi/examples $ scriba -f/etc/scriba/basic.conf.JRS  myip.sb
{
  "ip": "#4.#9.#1.#11",
  "hostname": "c-#4-#9-#1-#11.hsd1.wa.comcast.net",
  "city": "Mount Vernon",
  "region": "Washington",
  "country": "US",
  "loc": "48.4352,-122.2080",
  "postal": "98273",
  "org": "AS33650 Comcast Cable Communications, LLC"
}
pi@raspberrypi:~/sbrpi/examples $



It looks like the module path should be /usr/local/module/.

I was unable to run hellomain.sb as it couldn't find your libscriba.so. Enabling my /usr/lib/libscriba.so fixed it.


pi@raspberrypi:~/sbrpi/examples $ scriba hellomain.sb
(0): error &H10:The requested module can not be loaded.
pi@raspberrypi:~/sbrpi/examples $ scriba -d hellomain.sb
Searching installed module header file 'sbt.bas' ...
Checking installed module header file location '/usr/local/include/scriba/sbt.bas' Result=OK
Including file '/usr/local/include/scriba/sbt.bas'
dlopen failed.
dlerror message=libscriba.so: cannot open shared object file: No such file or directory
(0): error &H10:The requested module can not be loaded.
pi@raspberrypi:~/sbrpi/examples $ ls -l /usr/local/module/
total 496
-rwxr-xr-x 1 1001 1001 55488 Mar 27 22:49 cgi.so
-rwxr-xr-x 1 1001 1001 54400 Mar 27 22:49 curl.so
-rwxr-xr-x 1 1001 1001 22180 Mar 27 22:49 curses.so
-rwxr-xr-x 1 1001 1001 23428 Mar 27 22:49 dbg.so
-rwxr-xr-x 1 1001 1001 14652 Mar 27 22:49 hash.so
-rwxr-xr-x 1 1001 1001 54452 Mar 27 22:49 json.so
-rwxr-xr-x 1 1001 1001 28512 Mar 27 22:49 mt.so
-rwxr-xr-x 1 1001 1001 66132 Mar 27 22:49 mxml.so
-rwxr-xr-x 1 1001 1001 29064 Mar 27 22:49 mysql.so
-rwxr-xr-x 1 1001 1001 15196 Mar 27 22:49 odbc.so
-rwxr-xr-x 1 1001 1001 16060 Mar 27 22:49 sbt.so
-rwxr-xr-x 1 1001 1001 23608 Mar 27 22:49 sdbg.so
-rwxr-xr-x 1 1001 1001 15124 Mar 27 22:49 slre.so
-rwxr-xr-x 1 1001 1001 11280 Mar 27 22:49 sqlite.so
-rwxr-xr-x 1 1001 1001 10364 Mar 27 22:49 trial.so
-rwxr-xr-x 1 1001 1001 14348 Mar 27 22:49 t.so
-rwxr-xr-x 1 1001 1001  5584 Mar 27 22:49 ux.so
-rwxr-xr-x 1 1001 1001 14916 Mar 27 22:49 zlib.so
pi@raspberrypi:~/sbrpi/examples $
Title: Re: SB Pi
Post by: John on March 28, 2019, 05:50:17 PM
I seem to have a problem with your json module.

Code: Script BASIC
  1. INCLUDE json.bas
  2.  
  3. jarray = json::load("commits.json")
  4. for i = 0 to json::count(jarray)-1
  5.     obj = json::object(jarray,i)
  6.     print string(40,"-"),"\n"
  7.     print json::text(obj,"commit.author.name"),"\n"
  8.     print json::text(obj,"commit.author.date"),"\n"
  9.     print json::text(obj,"sha"),"\n"
  10. next
  11. print string(40,"-"),"\n"
  12.  


-rw-r--r-- 1 pi pi    23 Mar 22 15:53 test.sb
pi@raspberrypi:~/sbrpi/examples $ scriba parse.sb
(0): error &H68:The user function "json::load" is used but is not defined.
(0): error &H68:The user function "json::text" is used but is not defined.
(0): error &H68:The user function "json::text" is used but is not defined.
(0): error &H68:The user function "json::text" is used but is not defined.
pi@raspberrypi:~/sbrpi/examples $

Title: Re: SB Pi
Post by: AIR on March 28, 2019, 06:12:15 PM
Two things:


Code: Script BASIC
  1. INCLUDE json.bas
  2.  
  3. jarray = json::loadfile("commits.json")
  4. for i = 0 to json::count(jarray)-1
  5.     obj = json::object(jarray,i)
  6.     print string(40,"-"),"\n"
  7.     print json::get(obj,"commit.author.name"),"\n"
  8.     print json::get(obj,"commit.author.date"),"\n"
  9.     print json::get(obj,"sha"),"\n"
  10. next
  11. print string(40,"-"),"\n"
  12.  

Your "myip" works now with the new package.

AIR.
Title: Re: SB Pi
Post by: John on March 28, 2019, 06:15:44 PM
Thanks AIR!

I'll uninstall and install the new .deb and retry the examples.

Does this fix the can't find libscriba.so problem?

I've been running the install with sudo Is it needed?
Title: Re: SB Pi
Post by: John on March 28, 2019, 06:50:02 PM
The libscriba.so not found is still a problem on my Rpi. It works if I enable mine in /urs/lib.

The new json example now works.
Title: Re: SB Pi
Post by: John on March 28, 2019, 07:04:33 PM
I tried the regex example you pointed to but I'm getting the following errors even after changing the INCLUDE from RE to SLRE.

Code: Script BASIC
  1. import slre.bas
  2.  
  3. source = """You can see in the program that the vector 'JOKER' is declared as 'global'.
  4. Samsung has unveiled a 'flexible' display the company's 2018 developer conference in San Francisco.
  5. It's still very much in 'prototype' stage, but Samsung wanted to take the opportunity to show off
  6. how UI and UX works on a flexible display, so that 'developers' can make apps that optimize it."""
  7.  
  8. reQuery ="'([a-zA-Z]+)'"
  9.  
  10. i=1
  11. do until re::match(source,reQuery) = 0
  12.     print i,". ",re::$(1)
  13.     source = right(source, LEN(source)-instr(source,re::$(1)))
  14.     print
  15.     i=i+1
  16. loop
  17.  


pi@raspberrypi:~/sbrpi/examples $ scriba testre.sb
(0): error &H68:The user function "re::match" is used but is not defined.
(0): error &H68:The user function "re::$" is used but is not defined.
(0): error &H68:The user function "re::$" is used but is not defined.
pi@raspberrypi:~/sbrpi/examples $

Title: Re: SB Pi
Post by: AIR on March 28, 2019, 07:45:44 PM
SLRE <> RE

the old re module was removed a while ago and replaced with slre.

Code: Script BASIC
  1. include slre.bas
  2.  
  3. source = """'Samsung' has 'unveiled' a 'flexible' display the company's 2018 developer conference in San Francisco.
  4. It's still very much in 'prototype' stage, but Samsung wanted to take the opportunity to show off
  5. how UI and UX works on a flexible display, so that 'developers' can make 'apps' that optimize it."""
  6.  
  7. regex = "'(\\S+)' "
  8.  
  9.  
  10. i=1
  11. do until slre::match(regex, source,1)  < 0
  12.     print i,". ",slre::$(0)
  13.     source = right(source, LEN(source)-instr(source,slre::$(0)))
  14.     print
  15.     i=i+1
  16. loop

1. Samsung
2. unveiled
3. flexible
4. prototype
5. developers
6. apps


As far as libscriba not being found, it should exist in /usr/local/lib.  You will need to do:  "sudo ldconfig" since by default raspbian has no scheduled execution of that command like other distros may.  That's a one time deal, afaik.

AIR.
Title: Re: SB Pi
Post by: John on March 28, 2019, 07:56:51 PM
Your new slre example worked.

I did the sudo ldconfig after remarking out my /usr/lib version and SBT seems to work.

Title: Re: SB Pi
Post by: AIR on March 28, 2019, 07:57:45 PM
I'll probably add that to the deb package as a postinstall step...
Title: Re: SB Pi
Post by: John on March 28, 2019, 08:10:49 PM
I agree!

Would a ldconf also be needed with the uninstall?

Is there a runtime list of dependencies a user would need to install? MySQL and Apache (for sbhttpd) are obvious.
Title: Re: SB Pi
Post by: AIR on March 28, 2019, 08:41:16 PM
Contents of the DEBIAN/control file:

Package: ScriptBasic
Version: 2.1-1
Architecture: armhf
Depends: libcurl3-gnutls, libiodbc2, libmariadbclient18, libncurses5, libsqlite3-0, libssl1.1
Maintainer: scriptbasic@scriptbasic.org
Description: Basic Interpreter


If the dependencies are missing, the items in the 'depends' line won't be installed if you use 'dpkg' to do the installation.

HOWEVER, if you do: sudo apt install ./scriptbasic-2.1-armf.deb, apt will check if the dependencies listed are already installed.  If they're not, it will go ahead and install them for you. Note that these are the RUNTIME packages and not the DEV packages which are not required to run SB.

MySQL and Apache:  I would not add these to the dependencies for this package.

The reason being that not everyone is using those; some use lightttpd or nginx as alternatives to Apache.  I personally use CADDY for my webserver, which is faster than all of them.

For DB, you have MariaDB, NoSQL, and many others.

And what of those who simply want to check out SB as an easy to use alternative scripting language.  It may not sit well with them that additional software is installed that they have no intention of using.

So the choice should be up to the user wanting to use SB, and not the packager.

AIR.
Title: Re: SB Pi
Post by: John on March 28, 2019, 08:59:50 PM
The maintainer should be support@scriptbasic.org.

I thought SQLite was static linked requiring no dependencies.
Title: Re: SB Pi
Post by: AIR on March 28, 2019, 09:13:34 PM
Code: [Select]
riveraa@dpi:~/tmp/scriptbasic-2.1-armf/usr/local/lib/scriba $ ldd sqlite.so
linux-vdso.so.1 (0x7ec5d000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76eca000)
libsqlite3.so.0 => /usr/lib/arm-linux-gnueabihf/libsqlite3.so.0 (0x76dd7000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76dae000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76c6f000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76bf0000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76bdd000)
/lib/ld-linux-armhf.so.3 (0x76ef3000)
Title: Re: SB Pi
Post by: John on March 28, 2019, 09:51:02 PM
It seems I can't use your install for sbhttpd even if I use my basic.conf file. Are you sure the sbhttpd you compiled has your -f addition?

pi@raspberrypi:~ $ sudo sbhttpd -f/etc/scriba/basic.conf.JRS -start
Can not open panic log "(null)".
AppInit returned 1
pi@raspberrypi:~ $
Title: Re: SB Pi
Post by: John on March 28, 2019, 09:55:58 PM
It works if I rename your basic.conf and use mine. That tells me the -f option isn't working or absent.
Title: Re: SB Pi
Post by: AIR on March 28, 2019, 10:03:26 PM
I don't use shbttpd, and have never used it.  It's never been my focus.

So there is no configuration for it in the package or appimage.
Title: Re: SB Pi
Post by: John on March 28, 2019, 10:07:36 PM
It's not a problem as we can just show users how to extend their basic.conf for other features for DB support, security and multiple (proxy) server support.

BTW, the web browers that comes with the RPi is a PoS. Firefox is as stable as a rock.
Title: Re: SB Pi
Post by: John on March 29, 2019, 05:24:06 PM
AIR,

I want to get the deb and AppImage distributions on the Script BASIC forum as that is where most folks will search for it first. Are you in agreement they are ready to distribute?

I think we should suggest people use the apt method to install so any missing dependencies get installed.

Does the APT method allow an uninstall as well?
Title: Re: SB Pi
Post by: John on March 29, 2019, 08:36:48 PM
Raspberry Pi GPIO Programming in C (https://www.bigmessowires.com/2018/05/26/raspberry-pi-gpio-programming-in-c/)

The Raspberry Pi OS comes with a GPIO Sense HAT emulator that uses Python as the scripting language.

API Reference - Sense HAT (https://pythonhosted.org/sense-hat/api)

It would be nice to use this API from SB.
Title: Re: SB Pi
Post by: AIR on March 30, 2019, 12:24:06 AM
AIR,

I want to get the deb and AppImage distributions on the Script BASIC forum as that is where most folks will search for it first. Are you in agreement they are ready to distribute?

I think we should suggest people use the apt method to install so any missing dependencies get installed.

Does the APT method allow an uninstall as well?

Yes, APT allows uninstall.

So to install, you do:
Code: [Select]
sudo apt install ./scriptbasic-2.1-linux-armhf.deb
And to uninstall:
Code: [Select]
sudo apt remove scriptbasic-2.1-linux-armhf
Note that to uninstall, you pass the NAME of the package and not the path or extension.

I've updated the mkappimage.sh script and created a new mkdeb.sh script (replacing the old one), as well as pushed the IP module. 

Both the appimage and deb files will be created in a folder called "PACKAGES".

ALL are in the CLEANUP branch.  So you can generate (AND TEST) what you need to post on the SB forum.

IMPORTANT CAVEAT:  The mkdeb.sh is RasPi only at the moment.  I need to tweak it to support x86.

Script updated to auto detect armhf (RasPi) and amd64(x86_64 Linux).

One thing you will need to address is the SBT module.  Currently it requires that libscriba.so be in the ld path; that really needs to be setup to static link instead.


AIR.
Title: Re: SB Pi
Post by: John on March 30, 2019, 07:36:49 AM
Thanks AIR!

I'll start a SB Pi like thread on the ScriptBasic.org forum and get our current distributions posted.

The PiWars (https://twitter.com/Raspberry_Pi/status/1111950499090235392?s=19) is happening this weekend in Cambridge England.
Title: Re: SB Pi
Post by: John on March 30, 2019, 10:05:35 AM
AIR,

I'm trying to get a post on the ScriptBasic forum going so the PiWars party goers can have something to play with. Can you either send me the surrent DEB and AppImage or push it to the SB-DEV MASTER?

I tried building the cleanup source and now get a fail on the sbt.bas file creation.


scriba executable OK 
sbhttpd executable OK 
libscriba library OK 
MODULE curl:     dll OK   lib OK   bas OK 
MODULE mt:       dll OK   lib OK   bas OK 
MODULE sqlite:   dll OK   lib OK   bas OK 
MODULE curses:   dll OK   lib OK   bas OK 
MODULE sdbg:     dll OK   lib OK   bas OK 
MODULE mysql:    dll OK   lib OK   bas OK 
MODULE dbg:      dll OK   lib OK   bas OK 
MODULE json:     dll OK   lib OK   bas OK 
MODULE ip:       dll OK   lib OK   bas OK 
MODULE ux:       dll OK   lib OK   bas OK 
MODULE mxml:     dll OK   lib OK   bas OK 
MODULE slre:     dll OK   lib OK   bas OK 
MODULE hash:     dll OK   lib OK   bas OK 
MODULE zlib:     dll OK   lib OK   bas OK 
MODULE sbt:      dll OK   lib OK   bas FAIL
MODULE trial:    dll OK   lib OK   bas OK 
MODULE odbc:     dll OK   lib OK   bas OK 
MODULE cgi:      dll OK   lib OK   bas OK 
MODULE t:        dll OK   lib OK   bas OK 
Title: Re: SB Pi
Post by: AIR on March 30, 2019, 11:28:36 AM
Copy sbt.bas into the modules folder.

You didn't configure sbt to automatically generate it.
Title: Re: SB Pi
Post by: John on March 30, 2019, 11:45:10 AM
I just added it and it still gives me a FAIL for the sbt.bas

Code: C
  1. SLFST SBT_SLFST[] ={
  2.  
  3. { "versmodu" , versmodu },
  4. { "bootmodu" , bootmodu },
  5. { "finimodu" , finimodu },
  6. { "SB_New" , SB_New },
  7. { "SB_Configure" , SB_Configure },
  8. { "SB_Load" , SB_Load },
  9. { "SB_LoadStr" , SB_LoadStr },
  10. { "SB_Run" , SB_Run },
  11. { "SB_NoRun" , SB_NoRun },
  12. { "SB_ThreadStart" , SB_ThreadStart },
  13. { "SB_ThreadEnd" , SB_ThreadEnd },
  14. { "SB_GetVar" , SB_GetVar },
  15. { "SB_SetUndef" , SB_SetUndef },
  16. { "SB_SetInt" , SB_SetInt },
  17. { "SB_SetDbl" , SB_SetDbl },
  18. { "SB_SetStr" , SB_SetStr },
  19. { "SB_ResetVars" , SB_ResetVars },
  20. { "SB_msSleep" , SB_msSleep },
  21. { "SB_CallSub" , SB_CallSub },
  22. { "SB_CallSubArgs" , SB_CallSubArgs },
  23. { "SB_Destroy" , SB_Destroy },
  24. { NULL , NULL }
  25.   };
  26.  
Title: Re: SB Pi
Post by: John on March 30, 2019, 11:54:37 AM
BAS: sbt.bas fixed it. I forgot that what I added was for static linking.

Half Baked:  :(

Code: Script BASIC
  1. ' """
  2. FILE: sbt.bas
  3.  
  4. This is the BASIC import file for the module sbt.
  5.  
  6. This file was generated by headerer.pl from the file
  7. Do not edit this file, rather edit the file  and use
  8. headerer.pl to regenerate this file.
  9. """
  10.  
  11. module sbt
  12.  
  13. ' FUNCTION DECLARATIONS
  14. declare sub     :: alias "SB_New"         lib "sbt"
  15. declare sub     :: alias "SB_Configure"   lib "sbt"
  16. declare sub     :: alias "SB_Load"        lib "sbt"
  17. declare sub     :: alias "SB_LoadStr"     lib "sbt"
  18. declare sub     :: alias "SB_Run"         lib "sbt"
  19. declare sub     :: alias "SB_NoRun"       lib "sbt"
  20. declare sub     :: alias "SB_ThreadStart" lib "sbt"
  21. declare sub     :: alias "SB_ThreadEnd"   lib "sbt"
  22. declare sub     :: alias "SB_Destroy"     lib "sbt"
  23. declare sub     :: alias "SB_CallSub"     lib "sbt"
  24. declare sub     :: alias "SB_CallSubArgs" lib "sbt"
  25. declare sub     :: alias "SB_GetVar"      lib "sbt"
  26. declare sub     :: alias "SB_SetUndef"    lib "sbt"
  27. declare sub     :: alias "SB_SetInt"      lib "sbt"
  28. declare sub     :: alias "SB_SetDbl"      lib "sbt"
  29. declare sub     :: alias "SB_SetStr"      lib "sbt"
  30. declare sub     :: alias "SB_ResetVars"   lib "sbt"
  31. declare sub     :: alias "SB_msSleep"     lib "sbt"
  32.  
  33. end module
  34.  
Title: Re: SB Pi
Post by: AIR on March 30, 2019, 12:08:24 PM
For auto-generation of the BAS file, your interface.c file needs to know the name of the bas file.
Title: Re: SB Pi
Post by: John on March 30, 2019, 12:15:00 PM
So BAS: sbt.bas doesn't do it?

I tried to build an AppImage but it can't find its build tool.


pi@raspberrypi:~/sbrpi/sb-dev-cleanup $ ls -l mkappimage.sh
-rwxr-xr-x 1 pi pi 691 Mar 30 01:41 mkappimage.sh
pi@raspberrypi:~/sbrpi/sb-dev-cleanup $
pi@raspberrypi:~/sbrpi/sb-dev-cleanup $ ./mkappimage.sh
Missing appimagetool
pi@raspberrypi:~/sbrpi/sb-dev-cleanup $

Title: Re: SB Pi
Post by: AIR on March 30, 2019, 12:22:40 PM
So BAS: sbt.bas doesn't do it?

I tried to build an AppImage but it can't find its build tool.


pi@raspberrypi:~/sbrpi/sb-dev-cleanup $ ls -l mkappimage.sh
-rwxr-xr-x 1 pi pi 691 Mar 30 01:41 mkappimage.sh
pi@raspberrypi:~/sbrpi/sb-dev-cleanup $
pi@raspberrypi:~/sbrpi/sb-dev-cleanup $ ./mkappimage.sh
Missing appimagetool
pi@raspberrypi:~/sbrpi/sb-dev-cleanup $


Yes, BAS: sbt.bas will do it, but it's not in the interface file in any branch.

"Missing appimagetool" means that exactly.  It needs to be in your path and named "appimagetool".  With no extension.

EDIT:  I updated the interface C so it generates the BAS file in both branches.

Title: Re: SB Pi
Post by: John on March 30, 2019, 01:23:32 PM
That still doesn't explain why only the ALIAS function names are being populated.
Title: Re: SB Pi
Post by: John on March 30, 2019, 01:48:17 PM
Success!

Here is the SBT hellomain.sb script with the AppImage I built from your script.

pi@raspberrypi:~/sbrpi/examples $ sb hellomain.sb
Hello Thread
1
SBT
pi@raspberrypi:~/sbrpi/examples $

The mkdeb.sh seemed to work.



pi@raspberrypi:~/sbrpi/sb-dev-cleanup $ ./mkappimage.sh
appimagetool, continuous build (commit 915b76d), build 2071 built on 2019-03-30 11:58:15 UTC
WARNING: appstreamcli command is missing, please install it if you want to use AppStream metadata
Using architecture armhf
/tmp/tmp.fVFxzxs7zd should be packaged as /home/pi/sbrpi/sb-dev-cleanup/PACKAGES/sb.AppImage
Deleting pre-existing .DirIcon
Creating .DirIcon symlink based on information from desktop file
WARNING: AppStream upstream metadata is missing, please consider creating it
         in usr/share/metainfo/sb.appdata.xml
         Please see https://www.freedesktop.org/software/appstream/docs/chap-Quickstart.html#sect-Quickstart-DesktopApps
         for more information or use the generator at http://output.jsbin.com/qoqukof.
Generating squashfs...
Parallel mksquashfs: Using 4 processors
Creating 4.0 filesystem on /home/pi/sbrpi/sb-dev-cleanup/PACKAGES/sb.AppImage, block size 131072.
[===================================================================================================================================================================================================================\] 75/75 100%

Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
   compressed data, compressed metadata, compressed fragments, compressed xattrs
   duplicates are removed
Filesystem size 989.62 Kbytes (0.97 Mbytes)
   24.70% of uncompressed filesystem size (4005.96 Kbytes)
Inode table size 693 bytes (0.68 Kbytes)
   36.17% of uncompressed inode table size (1916 bytes)
Directory table size 508 bytes (0.50 Kbytes)
   56.13% of uncompressed directory table size (905 bytes)
Number of duplicate files found 0
Number of inodes 56
Number of files 49
Number of fragments 5
Number of symbolic links  1
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 6
Number of ids (unique uids + gids) 1
Number of uids 1
   root (0)
Number of gids 1
   root (0)
Embedding ELF...
Marking the AppImage as executable...
Embedding MD5 digest
Success

Please consider submitting your AppImage to AppImageHub, the crowd-sourced
central directory of available AppImages, by opening a pull request
at https://github.com/AppImage/appimage.github.io
pi@raspberrypi:~/sbrpi/sb-dev-cleanup $

Title: Re: SB Pi
Post by: John on March 30, 2019, 02:36:14 PM
I made the Raspberry Pi download post on the ScriptBasic.org forum.

AIR,

If someone uses the AppImage verion of ScriptBasic on a fresh Rpi, are the runtime dependencies installed? Do I need to add a list of required runtime dependencies?

Title: Re: SB Pi
Post by: AIR on March 30, 2019, 03:18:15 PM
No, they are not.  You can reference the mkdeb.sh script to see which libraries are required for the modules.  They are currently not included in the appimage.
Title: Re: SB Pi
Post by: John on March 30, 2019, 03:23:05 PM
Is it the same runtime list you posted earlier?

Can these be added to the AppImage?

I'll update the SciptBasic forum post with required dependences if using the AppImage and the ldconf fix if libscriba.so can'tt be found.
Title: Re: SB Pi
Post by: AIR on March 30, 2019, 03:26:21 PM
Look in the script, because they differ slightly between x86 and armhf.

It would help if you also did some of the research into building this stuff.

The deb package runs ldconfig as a postinstall step.
Title: Re: SB Pi
Post by: John on March 30, 2019, 03:32:43 PM
I'll give that a go as soon as I finish testing and promoting the RPi distribution

What we need is more people getting on board and helping the project out.
Title: Re: SB Pi
Post by: AIR on March 30, 2019, 03:38:45 PM
This is an example of why including the required libs in the appimage is a daunting task.

Checking the curl.so file yields:
Code: [Select]
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f23000)
libcurl-gnutls.so.4 => /usr/lib/arm-linux-gnueabihf/libcurl-gnutls.so.4 (0x76ea9000)
libssl.so.1.1 => /usr/lib/arm-linux-gnueabihf/libssl.so.1.1 (0x76e48000)
libcrypto.so.1.1 => /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.1 (0x76c72000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76c5f000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76b20000)
libnghttp2.so.14 => /usr/lib/arm-linux-gnueabihf/libnghttp2.so.14 (0x76af2000)
libidn2.so.0 => /usr/lib/arm-linux-gnueabihf/libidn2.so.0 (0x76ac0000)
librtmp.so.1 => /usr/lib/arm-linux-gnueabihf/librtmp.so.1 (0x76a97000)
libssh2.so.1 => /usr/lib/arm-linux-gnueabihf/libssh2.so.1 (0x76a62000)
libpsl.so.5 => /usr/lib/arm-linux-gnueabihf/libpsl.so.5 (0x76a45000)
libnettle.so.6 => /usr/lib/arm-linux-gnueabihf/libnettle.so.6 (0x769fe000)
libgnutls.so.30 => /usr/lib/arm-linux-gnueabihf/libgnutls.so.30 (0x76871000)
libgssapi_krb5.so.2 => /usr/lib/arm-linux-gnueabihf/libgssapi_krb5.so.2 (0x76828000)
libkrb5.so.3 => /usr/lib/arm-linux-gnueabihf/libkrb5.so.3 (0x76771000)
libk5crypto.so.3 => /usr/lib/arm-linux-gnueabihf/libk5crypto.so.3 (0x76732000)
libcom_err.so.2 => /lib/arm-linux-gnueabihf/libcom_err.so.2 (0x7671f000)
liblber-2.4.so.2 => /usr/lib/arm-linux-gnueabihf/liblber-2.4.so.2 (0x76703000)
libldap_r-2.4.so.2 => /usr/lib/arm-linux-gnueabihf/libldap_r-2.4.so.2 (0x766ae000)
libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0x76687000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x7665e000)
/lib/ld-linux-armhf.so.3 (0x76f56000)
libunistring.so.0 => /usr/lib/arm-linux-gnueabihf/libunistring.so.0 (0x7654f000)
libhogweed.so.4 => /usr/lib/arm-linux-gnueabihf/libhogweed.so.4 (0x76512000)
libgmp.so.10 => /usr/lib/arm-linux-gnueabihf/libgmp.so.10 (0x7649f000)
libgcrypt.so.20 => /lib/arm-linux-gnueabihf/libgcrypt.so.20 (0x763ce000)
libp11-kit.so.0 => /usr/lib/arm-linux-gnueabihf/libp11-kit.so.0 (0x76370000)
libidn.so.11 => /lib/arm-linux-gnueabihf/libidn.so.11 (0x7632f000)
libtasn1.so.6 => /usr/lib/arm-linux-gnueabihf/libtasn1.so.6 (0x7630f000)
libkrb5support.so.0 => /usr/lib/arm-linux-gnueabihf/libkrb5support.so.0 (0x762f6000)
libkeyutils.so.1 => /lib/arm-linux-gnueabihf/libkeyutils.so.1 (0x762e3000)
libresolv.so.2 => /lib/arm-linux-gnueabihf/libresolv.so.2 (0x762be000)
libsasl2.so.2 => /usr/lib/arm-linux-gnueabihf/libsasl2.so.2 (0x76297000)
libgpg-error.so.0 => /lib/arm-linux-gnueabihf/libgpg-error.so.0 (0x76277000)
libffi.so.6 => /usr/lib/arm-linux-gnueabihf/libffi.so.6 (0x7625f000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x76232000)

Those are all of the libraries that it links with.  I'm not willing to go down the rabbit hole of determining which ones can be omitted and run from the system installed libraries.

AIR.
Title: Re: SB Pi
Post by: John on March 30, 2019, 03:45:50 PM
Please look at my ScriptBasic forum post and see if I'm missing anything.
Title: Re: SB Pi
Post by: AIR on March 30, 2019, 05:41:54 PM
Looks okay, except that you shouldn't install anything not provided by the distro into /usr/bin.  Instead, use /usr/local/bin. 

On the PI, you should also be able to use ~/bin (create it if it doesn't exist.)

The .bashrc checks if it exists and adds it to your path.  You would either have to source .bashrc in order for it to pick this up immediately, or just exit the terminal and relaunch it.
Title: Re: SB Pi
Post by: AIR on March 30, 2019, 06:36:22 PM
Curl is really the only library that is an issue.

So I found a recipe for compiling it for an appimage.

This is what the freshly compiled libcurl shows on my RasPi:
Code: [Select]
riveraa@dpi:~/src $ ldd libcurl.so.4.5.0
linux-vdso.so.1 (0x7ec6e000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76e60000)
libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0x76e39000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76e10000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76cd1000)
/lib/ld-linux-armhf.so.3 (0x76eda000)

HUGE difference, all the SSL stuff is statically linked now.

libmariadbclient,libsqlite3, and libiodbc/libiodbcinst are self contained, other than the usual system libraries.

So I manually created an appimage, including the libraries in it, and it seems to work okay.

I've attached the test RasPi appimage for testing purposes.

AIR.
Title: Re: SB Pi
Post by: John on March 30, 2019, 10:58:13 PM
Outstanding!

I'll give e this a good test in a bit.
Title: Re: SB Pi
Post by: John on March 31, 2019, 12:37:13 AM
It seems the suggestion to use bin in my home directory didn't work for me. (even after a reboot) I installed the sb AppImage in the /usr/local/bin and that worked fine. All my tests seem to work so I'm going to replace the AppImage zip on the ScriptBasic forum with your new version and cleanup the post.

Code: [Select]
pi@raspberrypi:~/sbrpi/examples $ sb myip.sb
{
  "ip": "#4.#9.#1.#11",
  "hostname": "c-#4-#9-#1-#11.hsd1.wa.comcast.net",
  "city": "Mount Vernon",
  "region": "Washington",
  "country": "US",
  "loc": "48.4352,-122.2080",
  "postal": "98273",
  "org": "AS33650 Comcast Cable Communications, LLC"
}
pi@raspberrypi:~/sbrpi/examples $ sb hellomain.sb
Hello Thread
1
SBT
pi@raspberrypi:~/sbrpi/examples $ sb sqlite_demo.sb
123 - hello
234 - cruel
345 - world
pi@raspberrypi:~/sbrpi/examples $ sb testmysql.sb
S18_1662 - 1980s Black Hawk Helicopter
S18_2581 - P-51-D Mustang
S24_1785 - 1928 British Royal Navy Airplane
S24_2841 - 1900s Vintage Bi-Plane
S24_3949 - Corsair F4U ( Bird Cage)
S24_4278 - 1900s Vintage Tri-Plane
S700_1691 - American Airlines: B767-300
S700_2466 - America West Airlines B757-200
S700_2834 - ATA: B757-300
S700_3167 - F/A 18 Hornet 1/72
S700_4002 - American Airlines: MD-11S
S72_1253 - Boeing X-32A JSF

The database handle is: 1
Affected rows by SELECT: 12
Character set name is: latin1
Last error is:
Client info is: 10.1.37-MariaDB
Host info is: Localhost via UNIX socket
Proto info is: 10
Server info is: 10.1.37-MariaDB-0+deb9u1
PING result: -1
Thread ID: 0
Status is: Uptime: 636  Threads: 1  Questions: 2  Slow queries: 0  Opens: 18  Flush tables: 1  Open tables: 12  Queries per second avg: 0.003
pi@raspberrypi:~/sbrpi/examples $ sb parse.sb
----------------------------------------
Linus Torvalds
2018-11-24T20:58:47Z
e195ca6cb6f21633e56322d5aa11ed59cdb22fb2
----------------------------------------
Linus Torvalds
2018-11-24T17:42:32Z
d146194f31c96f9b260c5a1cf1592d2e7f82a2e2
----------------------------------------
Linus Torvalds
2018-11-24T17:19:38Z
857fa628bbe93017c72ddd0d5304962a2608db07
----------------------------------------
Linus Torvalds
2018-11-24T17:11:52Z
abe72ff4134028ff2189d29629c40a40bee0a989
----------------------------------------
Andreas Fiedler
2018-11-23T23:16:34Z
07093b76476903f820d83d56c3040e656fb4d9e3
----------------------------------------
Quentin Schulz
2018-11-23T18:01:51Z
3fa528b7682e73e906266bcd43728b8f923bf9b2
----------------------------------------
Fabio Estevam
2018-11-23T17:46:50Z
e7b9fb4f545b1f7885e7c642643828f93d3d79c9
----------------------------------------
Lorenzo Bianconi
2018-11-23T17:28:01Z
ef2a7cf1d8831535b8991459567b385661eb4a36
----------------------------------------
Yangtao Li
2018-11-22T12:34:41Z
c44c749d3b6fdfca39002e7e48e03fe9f9fe37a3
----------------------------------------
Hangbin Liu
2018-11-22T08:15:28Z
5ed9dc99107144f83b6c1bb52a69b58875baf540
----------------------------------------
Jason Wang
2018-11-22T06:36:31Z
18ba58e1c234ea1a2d9835ac8c1735d965ce4640
----------------------------------------
Jason Wang
2018-11-22T06:36:30Z
e59ff2c49ae16e1d179de679aca81405829aee6c
----------------------------------------
Linus Torvalds
2018-11-23T19:24:55Z
7c98a42618271210c60b79128b220107d35938d9
----------------------------------------
Linus Torvalds
2018-11-23T19:20:14Z
3381918fec9278d14f776d1dabd68da85fd6822e
----------------------------------------
Davide Caratti
2018-11-21T17:23:53Z
484afd1bd3fc6f9f5347289fc8b285aa65f67054
----------------------------------------
Paolo Abeni
2018-11-21T17:21:35Z
605108acfe6233b72e2f803aa1cb59a2af3001ca
----------------------------------------
Hangbin Liu
2018-11-21T13:52:33Z
896585d48e8e9ba44cd1754fbce8537feffcc1a5
----------------------------------------
Linus Torvalds
2018-11-23T19:15:27Z
d88783b9c8849d88c3a75b7b9071cba072b47eba
----------------------------------------
Willem de Bruijn
2018-11-20T18:00:18Z
5cd8d46ea1562be80063f53c7c6a5f40224de623
----------------------------------------
Linus Torvalds
2018-11-23T18:56:16Z
a03bac580ae743d5900af626ac63f7f8cd85def9
----------------------------------------
Linus Torvalds
2018-11-23T18:52:57Z
b88af994872418f0a98db6f4a9bae849315a99b0
----------------------------------------
Will Deacon
2018-11-21T15:07:00Z
4f9f49646a5733c0c2bd49940673dde89a9c5add
----------------------------------------
Linus Torvalds
2018-11-23T18:40:19Z
e6005d3c42336074de3745718ac85807dd6e1e6a
----------------------------------------
Linus Torvalds
2018-11-23T18:36:02Z
dcd3aa31dcdd6d8eae8d4771c44aeb3b1fec995a
----------------------------------------
Linus Torvalds
2018-11-23T18:03:08Z
9b7c880c834c0a1c80a1dc6b8a0b19155361321f
----------------------------------------
Sergey Matyukevich
2018-11-16T18:21:30Z
b5d9a07ef7736b2456b9d3c90568de25e43d8ec3
----------------------------------------
Rafael J. Wysocki
2018-11-23T09:32:49Z
1d50088ca3956e5dcd2751a658e7869b9af10bb4
----------------------------------------
Rafael J. Wysocki
2018-11-23T09:32:22Z
bec00cb5e97c19d2c8bd10db15d334cb40760000
----------------------------------------
Dave Airlie
2018-11-23T01:03:20Z
98c9cdfd34fbb62886e4c5a07e33661aa3352ef5
----------------------------------------
David S. Miller
2018-11-22T19:53:26Z
039e70a70c8417b5bf5878a60612ebd2c95f731e
----------------------------------------
pi@raspberrypi:~/sbrpi/examples $ sb testre.sb
1. Samsung
2. unveiled
3. flexible
4. prototype
5. developers
6. apps
pi@raspberrypi:~/sbrpi/examples $ sb testmxml.sb
Test1: This is a test!
Test2: And this is another test!

Image: madonna.jpg
Alt Image: Foligno Madonna, by Raphael

ID = 1
Name = Hello, world!
ID = 2
Name = Hello, China!
pi@raspberrypi:~/sbrpi/examples $

Thank You !
Title: Re: SB Pi
Post by: John on March 31, 2019, 01:54:43 AM
I was able to install gedit which is a much better text editor than what comes stock with the RPi. Language syntax highlighting is easily added using a XML file definition. I'm going to try and build something for SB.

I also installed GIMP for image editing.
Title: Re: SB Pi
Post by: John on March 31, 2019, 02:10:04 PM
I was able to get the BBC BASIC graphics extension module working on the Raspberry Pi.

Code: Script BASIC
  1. ' UFO
  2.  
  3. IMPORT bbc.bas
  4.  
  5. BBC::OPEN "ScriptBasic BBC UFO - Raspberry PI"
  6. t1 = BBC::TIME()
  7. BBC::MODE 31
  8. BBC::ORIGIN 800, 600
  9. xs = 2
  10. ys = 2
  11. BBC::GCOL 0, 14
  12. BBC::OFF
  13. a = 700
  14. b = A * A
  15. c = 600
  16. FOR x = 0 TO a STEP xs
  17.   s = x * x
  18.   p = SQR(b - s)
  19.   FOR i = -p TO p STEP 6 * ys
  20.     r = SQR(s + i * i) / a
  21.     q = (r - 1) * SIN(24 * r)
  22.     y = INT(i / 3 + q * c)
  23.     IF i = -p THEN
  24.       m = y
  25.       n = y
  26.     END IF
  27.     IF y > m THEN m = y
  28.     IF y < n THEN n = y
  29.     IF m = y OR n = y THEN
  30.       BBC::PLOT 69, NOT(x), y
  31.       BBC::PLOT 69, x, y
  32.     END IF
  33.   NEXT
  34. NEXT
  35. t2 = BBC::TIME()
  36. t3 = (t2 - t1) / 1000
  37. BBC::OFF
  38. BBC::VDUSTR "Time: " & FORMAT("%.4f", t3) & " seconds."
  39. WHILE BBC::KEYNAME(1) <> "-escape"
  40. WEND
  41. BBC::CLOSE
  42.  

Title: Re: SB π
Post by: John on March 31, 2019, 03:41:26 PM
Here is the Fren example.

Code: Script BASIC
  1. ' Fern
  2.  
  3. IMPORT bbc.bas
  4.  
  5. BBC::OPEN "ScriptBasic BBC fern - Raspbery Pi"
  6. t1 = BBC::TIME()
  7. BBC::MODE 31
  8. BBC::ORIGIN 200, 100
  9. BBC::OFF
  10. BBC::GCOL 0, 10
  11. x = 0
  12. y = 0
  13. FOR i = 1 TO 80000
  14.   r = BBC::RND(1)
  15.   IF r <= 0.1 THEN
  16.     a = 0
  17.     b = 0
  18.     c = 0
  19.     d = 0.16
  20.     e = 0
  21.     f = 0
  22.   END IF
  23.   IF r > 0.1 AND r <= 0.86 THEN
  24.     a = .85
  25.     b = .04
  26.     c = -.04
  27.     d = .85
  28.     e = 0
  29.     f = 1.6
  30.   END IF
  31.   IF r > 0.86 AND r <= 0.93 THEN
  32.     a = .2
  33.     b = -.26
  34.     c = .23
  35.     d = .22
  36.     e = 0
  37.     f = 1.6
  38.   END IF
  39.   IF r > 0.93 THEN
  40.     a = -.15
  41.     b = .28
  42.     c = .26
  43.     d = .24
  44.     e = 0
  45.     f = .44
  46.   END IF
  47.   newx = a * x + b * y + e
  48.   newy = c * x + d * y + f
  49.   x = newx
  50.   y = newy
  51.   BBC::MOVE 600 + 96 * x, 32 + 96 * y
  52.   BBC::DRAW 600 + 96 * x, 32 + 96 * y
  53. NEXT i
  54. t2 = BBC::TIME()
  55. t3 = (t2-t1)/1000
  56. BBC::VDUSTR "Time: " & FORMAT("%.4f",t3) & " seconds"
  57. BBC::WAITKEY
  58. BBC::CLOSE
  59.  
Title: Re: SB π
Post by: John on March 31, 2019, 03:58:48 PM
Finally the graph example. Hopefully other BBC BASIC fans will contribute examples as well.

Code: Script BASIC
  1. ' Graph Demo
  2.  
  3. IMPORT bbc.bas
  4.  
  5. CONST SDLK_ESCAPE = 27
  6.  
  7. BBC::OPEN "ScriptBasic BBC graphdemo - Raspberry Pi"
  8. t1 = BBC::TIME()
  9. BBC::MODE 31
  10. BBC::ORIGIN 800, 600
  11. xlow = -10
  12. xhigh = 10
  13. ylow = -10
  14. yhigh = 10
  15. depth = 10
  16. xscale = 30
  17. yscale = 12
  18. c = -4000
  19.  
  20. FOR x = xlow TO xhigh
  21.   BBC::MOVE xscale * (x + ylow), yscale * (ylow - x) + c / (x * x + ylow * ylow + depth)
  22.   FOR y = ylow TO yhigh
  23.     BBC::DRAW xscale * (x + y), yscale * (y - x) + c / (x * x + y * y + depth)
  24.   NEXT
  25. NEXT
  26. FOR y = ylow TO yhigh
  27.   BBC::MOVE xscale * (xlow + y), yscale * (y - xlow) + c / (xlow * xlow + y * y + depth)
  28.   FOR x = xlow TO xhigh
  29.     BBC::DRAW xscale * (x + y), yscale * (y - x) + c / (x * x + y * y + depth)
  30.   NEXT
  31. NEXT
  32. t2 = BBC::TIME()
  33. t3 = (t2 - t1) / 1000
  34. BBC::OFF
  35. BBC::VDUSTR "Time: " & FORMAT("%.4f", t3) & " seconds."
  36. WHILE BBC::GETKEY(1) <> SDLK_ESCAPE
  37. WEND
  38. BBC::CLOSE
  39.  
Title: Re: SB π
Post by: John on March 31, 2019, 05:21:04 PM
For those not into the retro BBC BASIC graphics primitives, I ported the SDL_gfx extension module to the Raspberry Pi.

Code: Script BASIC
  1. ' ScriptBasic GFX - Alpha Circles
  2.  
  3. IMPORT gfx.bas
  4.  
  5. scrn = gfx::Window(640, 480, "ScriptBasic GFX - Alpha Circles - Raspberry Pi")
  6. ' Random Value Arrays
  7. RANDOMIZE(gfx::Time())
  8. FOR i = 0 TO 512
  9.   rx[i] = RND() % 640
  10.   ry[i] = 60 + RND() % 480 - 80
  11.   rz[i] = RND() % 64
  12.   rr[i] = RND() AND  255
  13.   rg[i] = RND() AND  255
  14.   rb[i] = RND() AND  255
  15.   af = rx[i] / 640
  16.   ra[i] = INT(255 * af)
  17. NEXT
  18.  
  19. ts = gfx::Time()
  20. FOR i = 0 TO 512
  21.   gfx::filledCircleRGBA scrn, rx[i], ry[i], rz[i], rr[i], rg[i], rb[i], ra[i]
  22. NEXT
  23. te = gfx::Time()
  24. gfx::stringColor scrn, 20, 15, "Time: " & FORMAT("%.4f",(te-ts)/1000) & " Seconds." & CHR(0), 0xffffffff
  25. gfx::Update
  26. WHILE gfx::KeyName(1) <> "+escape"
  27. WEND
  28. gfx::Close
  29.  
Title: Re: SB π
Post by: John on March 31, 2019, 05:32:48 PM
This shows some of the SDL_gfx graphic primitives.

Code: Script BASIC
  1. ' SDL_gfx Demo
  2.  
  3. IMPORT gfx.bas
  4.  
  5. screen = gfx::Window(700, 600, "ScriptBasic GFX Demo - Raspberry Pi")
  6. gfx::pixelRGBA(screen, 10, 15, 255, 255, 255, 255)
  7. gfx::lineRGBA(screen, 20, 10, 70, 90, 255, 0, 0, 255)
  8. gfx::trigonRGBA(screen, 500, 50, 550, 200, 600, 150, 0, 255, 255, 255)
  9. gfx::filledTrigonRGBA(screen, 200, 200, 300, 50, 400, 200, 0, 0, 255, 255)
  10. gfx::rectangleRGBA(screen, 10, 300, 100, 380, 0, 255, 0, 255)
  11. gfx::boxRGBA(screen, 210, 76, 325, 300, 255, 0, 0, 150)
  12. gfx::ellipseRGBA(screen, 600, 400, 50, 90, 255, 255, 0, 200)
  13. gfx::filledEllipseRGBA(screen, 600, 400, 25, 150, 0, 255, 0, 255)
  14. x[0] = 350
  15. x[1] = 275
  16. x[2] = 300
  17. x[3] = 325
  18. x[4] = 350
  19. x[5] = 400
  20. y[0] = 325
  21. y[1] = 325
  22. y[2] = 390
  23. y[3] = 390
  24. y[4] = 375
  25. gfx::polygonRGBA(screen, x, y, 6, 255, 255, 255, 155)
  26. s[0] = 400
  27. s[1] = 450
  28. s[2] = 450
  29. s[3] = 425
  30. s[4] = 300
  31. t[0] = 400
  32. t[1] = 410
  33. t[2] = 450
  34. t[3] = 425
  35. t[4] = 500
  36. gfx::filledPolygonRGBA(screen, s, t, 5, 255, 0, 255, 155)
  37. gfx::Update
  38. WHILE gfx::KeyName(1) <> "+escape"
  39. WEND
  40. gfx::Close
  41.  
Title: Re: SB π
Post by: John on March 31, 2019, 06:53:29 PM
I'm pleased  to announce a release of ScriptBasic for the Raspberry Pi. You can do a traditional install with a .deb file or as an AppImage.

DEB Install:

Code: Bash
  1. sudo apt install ./scriptbasic-2.1-linux-armhf.deb

DEB Uninstall:

Code: Bash
  1. sudo apt remove scriptbasic-2.1-linux-armhf

To run a script use scriba <script nane> when using the DEB Install.

To use the AppImage version ScriptBasic, unzip the file in the /usr/local/bin (or a directory in the system path) and use sb <script_name> to run your scripts. To remove ScriptBasic, remove the sb file.


ScriptBasic User and Developer Guides (https://scriptbasic.org/wiki/)

Most of the ScriptBasic development activity is happening on the All BASIC Forum (https://allbasic.info/forum/).

Language Features

Extension Modules

Free - Open Source - MIT License



Attached are the extension modules and dependencies need for the bbc and gfx extension modules. These extension only work with the DEB install at this time.

One must install the SDL 1.2 and SDL_gfx 1.2 runtime libraries.

sudo apt-get install libsdl1.2debian-1.2.15+dfsg1-4+rpt2
sudo apt-get install libsdl-gfx1.2-5-2.0.25-5

BBC
1. unzip the bbc.zip file in a temp directory
2. sudo cp bbc.so /usr/local/lib/scriba/
3. sudo cp bbc.bas /usr/local/include/scriba/
4. sudo cp libbbc.so /usr/lib/


SDL_gfx
1. unzip the gfx.zip file in a temp directory
2. sudo cp gfx.so /usr/local/lib/scriba/
3. sudo cp gfx.bas /usr/local/include/scriba/

Use the ScriptBasic example code posted in this thread to test your installation.
Title: Re: SB π
Post by: John on April 01, 2019, 02:37:21 PM
I just ordered a Raspberry Pi Sense HAT board. I want to get a GPIO extension module going with ScriptBasic The Sense HAT emulator that comes with the RPi uses Python as its scripting langauage. It would be cool to be able to script the emulator with SB.

Essentials Sense HAT (https://scriptbasic.org/download/Essentials_SenseHAT_v1.pdf)
Title: Re: SB π
Post by: John on April 01, 2019, 03:22:12 PM
I was able to find the xml syntax definition file for gEdit that BaCon uses. Since BaCon is so close to SB syntax, using it as a template should make creating a SB version easy.

Code: XML
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4. Author: Peter van Eerten <peter@basic-converter.org>
  5. Copyright (C) 2010 Peter van Eerten <peter@basic-converter.org>
  6.  
  7. Language: BaCon (BAsic CONverter)
  8. Last Change: December 22, 2018
  9.  
  10. This library is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU Library General Public
  12. License as published by the Free Software Foundation; either
  13. version 2 of the License, or (at your option) any later version.
  14.  
  15. This library is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18. Library General Public License for more details.
  19.  
  20. You should have received a copy of the GNU Library General Public
  21. License along with this library; if not, write to the
  22. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  23. Boston, MA 02111-1307, USA.
  24.  
  25.    =========================
  26.    INSTALLATION INSTRUCTIONS
  27.    =========================
  28.  
  29. (1) Create language directory for GtkSourceView:
  30.  
  31.    mkdir -p ~/.local/share/gtksourceview-2.0/language-specs/
  32.  
  33. (2) Copy this file to the new directory:
  34.  
  35.    cp bacon.lang ~/.local/share/gtksourceview-2.0/language-specs/
  36.  
  37.  
  38. Now start gedit, Anjuta, Scribes etc and the BaCon sourcecode has
  39.   syntax highlighting!
  40. -->
  41.  
  42. <language id="bacon" _name="BaCon" version="2.0" _section="Sources">
  43.  
  44. <metadata>
  45.     <property name="mimetypes">text/x-bac</property>
  46.     <property name="globs">*.bac</property>
  47.     <property name="line-comment-start">'</property>
  48. </metadata>
  49.  
  50. <styles>
  51.     <style id="comment"             _name="Comment"             map-to="def:comment"/>
  52.     <style id="shebang"             _name="Shebang"             map-to="def:shebang"/>
  53.     <style id="function"            _name="Function"            map-to="def:function"/>
  54.     <style id="string"              _name="String"              map-to="def:string"/>
  55.     <style id="keyword"             _name="Keyword"             map-to="def:keyword"/>
  56.     <style id="special-constant"    _name="Special constant"    map-to="def:special-constant"/>
  57.     <style id="boolean"             _name="Boolean value"       map-to="def:boolean"/>
  58.     <style id="type"                _name="Data Type"           map-to="def:type"/>
  59.     <style id="operator"            _name="Operator"            map-to="def:operator"/>
  60.     <style id="wrapperfunc"         _name="Wrapper"             map-to="def:preprocessor"/>
  61. </styles>
  62.  
  63. <!-- <default-regex-options case-sensitive="false"/> -->
  64.  
  65. <definitions>
  66.  
  67.     <context id="line-comment" style-ref="comment" end-at-line-end="true">
  68.         <start>'</start>
  69.             <include>
  70.                 <context ref="def:in-line-comment"/>
  71.             </include>
  72.     </context>
  73.  
  74.     <context id="old-style-comment" style-ref="comment" end-at-line-end="true">
  75.         <start>REM</start>
  76.             <include>
  77.                 <context ref="def:in-line-comment"/>
  78.             </include>
  79.     </context>
  80.  
  81.     <context id="multiline-comment" style-ref="comment">
  82.         <start>\/\*</start>
  83.         <end>\*\/</end>
  84.             <include>
  85.                 <context ref="def:in-line-comment"/>
  86.             </include>
  87.     </context>
  88.  
  89.     <context id="string" style-ref="string">
  90.       <start>"</start>
  91.       <end>"</end>
  92.       <include>
  93.         <!-- highlight escaped chars -->
  94.         <context style-ref="def:special-char">
  95.             <match>\\[$`"\\]</match>
  96.         </context>
  97.         <!-- skip backslash where it's not an escaping char -->
  98.         <context>
  99.             <match>\\</match>
  100.         </context>
  101.         <context ref="def:line-continue"/>
  102.       </include>
  103.     </context>
  104.  
  105.     <context id="function" style-ref="function">
  106.         <keyword>ABS</keyword>
  107.         <keyword>ACOS</keyword>
  108.         <keyword>ADDRESS</keyword>
  109.         <keyword>AMOUNT</keyword>
  110.         <keyword>AND</keyword>
  111.         <keyword>ASC</keyword>
  112.         <keyword>ASIN</keyword>
  113.         <keyword>ATN</keyword>
  114.         <keyword>ATN2</keyword>
  115.         <keyword>BETWEEN</keyword>
  116.         <keyword>BIT</keyword>
  117.         <keyword>BLOAD</keyword>
  118.         <keyword>BYTELEN</keyword>
  119.         <keyword>CEIL</keyword>
  120.         <keyword>CMDLINE</keyword>
  121.         <keyword>COLUMNS</keyword>
  122.         <keyword>COS</keyword>
  123.         <keyword>COUNT</keyword>
  124.         <keyword>DAY</keyword>
  125.         <keyword>DEC</keyword>
  126.         <keyword>DEG</keyword>
  127.         <keyword>ENDFILE</keyword>
  128.         <keyword>EQUAL</keyword>
  129.         <keyword>ERROR</keyword>
  130.         <keyword>EVAL</keyword>
  131.         <keyword>EVEN</keyword>
  132.         <keyword>EXCL</keyword>
  133.         <keyword>EXP</keyword>
  134.         <keyword>FILEEXISTS</keyword>
  135.         <keyword>FILELEN</keyword>
  136.         <keyword>FILETIME</keyword>
  137.         <keyword>FILETYPE</keyword>
  138.         <keyword>FLOOR</keyword>
  139.         <keyword>FORK</keyword>
  140.         <keyword>FP</keyword>
  141.         <keyword>GETKEY</keyword>
  142.         <keyword>GETX</keyword>
  143.         <keyword>GETY</keyword>
  144.         <keyword>HASH</keyword>
  145.         <keyword>HOUR</keyword>
  146.         <keyword>IIF</keyword>
  147.         <keyword>INSTR</keyword>
  148.         <keyword>INSTRREV</keyword>
  149.         <keyword>INT</keyword>
  150.         <keyword>ISASCII</keyword>
  151.         <keyword>ISFALSE</keyword>
  152.         <keyword>ISKEY</keyword>
  153.         <keyword>ISTOKEN</keyword>
  154.         <keyword>ISTRUE</keyword>
  155.         <keyword>LEN</keyword>
  156.         <keyword>LOG</keyword>
  157.         <keyword>MAX</keyword>
  158.         <keyword>MAXNUM</keyword>
  159.         <keyword>MEMCHECK</keyword>
  160.         <keyword>MEMORY</keyword>
  161.         <keyword>MEMTELL</keyword>
  162.         <keyword>MIN</keyword>
  163.         <keyword>MINUTE</keyword>
  164.         <keyword>MOD</keyword>
  165.         <keyword>MONTH</keyword>
  166.         <keyword>MYPID</keyword>
  167.         <keyword>NOT</keyword>
  168.         <keyword>NOW</keyword>
  169.         <keyword>NRKEYS</keyword>
  170.         <keyword>ODD</keyword>
  171.         <keyword>OR</keyword>
  172.         <keyword>PEEK</keyword>
  173.         <keyword>POW</keyword>
  174.         <keyword>RAD</keyword>
  175.         <keyword>RANDOM</keyword>
  176.         <keyword>REGEX</keyword>
  177.         <keyword>REAP</keyword>
  178.         <keyword>RND</keyword>
  179.         <keyword>ROL</keyword>
  180.         <keyword>ROR</keyword>
  181.         <keyword>ROUND</keyword>
  182.         <keyword>ROWS</keyword>
  183.         <keyword>RUN</keyword>
  184.         <keyword>SEARCH</keyword>
  185.         <keyword>SECOND</keyword>
  186.         <keyword>SGN</keyword>
  187.         <keyword>SIN</keyword>
  188.         <keyword>SIZEOF</keyword>
  189.         <keyword>SQR</keyword>
  190.         <keyword>SUM</keyword>
  191.         <keyword>SUMF</keyword>
  192.         <keyword>TALLY</keyword>
  193.         <keyword>TAN</keyword>
  194.         <keyword>TELL</keyword>
  195.         <keyword>TIMER</keyword>
  196.         <keyword>TIMEVALUE</keyword>
  197.         <keyword>UCS</keyword>
  198.         <keyword>ULEN</keyword>
  199.         <keyword>VAL</keyword>
  200.         <keyword>WAIT</keyword>
  201.         <keyword>WEEK</keyword>
  202.         <keyword>YEAR</keyword>
  203.     </context>
  204.  
  205.     <context id="keywords" style-ref="keyword">
  206.         <keyword>ALARM</keyword>
  207.         <keyword>ALIAS</keyword>
  208.         <keyword>APPENDING</keyword>
  209.         <keyword>APPEND</keyword>
  210.         <keyword>ARRAY</keyword>
  211.         <keyword>AS</keyword>
  212.         <keyword>ASSOC</keyword>
  213.         <keyword>BACONLIB</keyword>
  214.         <keyword>BACK</keyword>
  215.         <keyword>BAPPEND</keyword>
  216.         <keyword>BASE</keyword>
  217.         <keyword>BG</keyword>
  218.         <keyword>BLACK</keyword>
  219.         <keyword>BLUE</keyword>
  220.         <keyword>BREAK</keyword>
  221.         <keyword>BROADCAST</keyword>
  222.         <keyword>BSAVE</keyword>
  223.         <keyword>BY</keyword>
  224.         <keyword>CALL</keyword>
  225.         <keyword>CASE</keyword>
  226.         <keyword>CATCH</keyword>
  227.         <keyword>CHANGEDIR</keyword>
  228.         <keyword>CHUNK</keyword>
  229.         <keyword>CLEAR</keyword>
  230.         <keyword>CLOSE</keyword>
  231.         <keyword>CMODE</keyword>
  232.         <keyword>COLLAPSE</keyword>
  233.         <keyword>COLOR</keyword>
  234.         <keyword>CONST</keyword>
  235.         <keyword>COMPARE</keyword>
  236.         <keyword>COMPILER</keyword>
  237.         <keyword>CONTINUE</keyword>
  238.         <keyword>COPY</keyword>
  239.         <keyword>CURRENT</keyword>
  240.         <keyword>CURSOR</keyword>
  241.         <keyword>CYAN</keyword>
  242.         <keyword>DATA</keyword>
  243.         <keyword>DECLARE</keyword>
  244.         <keyword>DECR</keyword>
  245.         <keyword>DEFAULT</keyword>
  246.         <keyword>DEF</keyword>
  247.         <keyword>DELETE</keyword>
  248.         <keyword>DELIM</keyword>
  249.         <keyword>DEVICE</keyword>
  250.         <keyword>DIRECTORY</keyword>
  251.         <keyword>DO</keyword>
  252.         <keyword>DONE</keyword>
  253.         <keyword>DOTIMES</keyword>
  254.         <keyword>DOWN</keyword>
  255.         <keyword>DOWNTO</keyword>
  256.         <keyword>DQ</keyword>
  257.         <keyword>ELIF</keyword>
  258.         <keyword>ELSE</keyword>
  259.         <keyword>ENDFORK</keyword>
  260.         <keyword>ENDFUNCTION</keyword>
  261.         <keyword>ENDRECORD</keyword>
  262.         <keyword>ENDIF</keyword>
  263.         <keyword>END</keyword>
  264.         <keyword>ENDSELECT</keyword>
  265.         <keyword>ENDSUB</keyword>
  266.         <keyword>ENDENUM</keyword>
  267.         <keyword>ENDUSEC</keyword>
  268.         <keyword>ENDUSEH</keyword>
  269.         <keyword>ENDWITH</keyword>
  270.         <keyword>ENUM</keyword>
  271.         <keyword>EPRINT</keyword>
  272.         <keyword>EQ</keyword>
  273.         <keyword>EXIT</keyword>
  274.         <keyword>EXPLICIT</keyword>
  275.         <keyword>FG</keyword>
  276.         <keyword>FI</keyword>
  277.         <keyword>FILE</keyword>
  278.         <keyword>FN</keyword>
  279.         <keyword>FOR</keyword>
  280.         <keyword>FORMAT</keyword>
  281.         <keyword>FORWARD</keyword>
  282.         <keyword>FRAMEWORK</keyword>
  283.         <keyword>FREE</keyword>
  284.         <keyword>FROM</keyword>
  285.         <keyword>FUNCTION</keyword>
  286.         <keyword>GE</keyword>
  287.         <keyword>GETBYTE</keyword>
  288.         <keyword>GETFILE</keyword>
  289.         <keyword>GETLINE</keyword>
  290.         <keyword>GLOBAL</keyword>
  291.         <keyword>GOSUB</keyword>
  292.         <keyword>GOTO</keyword>
  293.         <keyword>GOTOXY</keyword>
  294.         <keyword>GREEN</keyword>
  295.         <keyword>GT</keyword>
  296.         <keyword>IF</keyword>
  297.         <keyword>IMODE</keyword>
  298.         <keyword>IMPORT</keyword>
  299.         <keyword>IN</keyword>
  300.         <keyword>INCLUDE</keyword>
  301.         <keyword>INCR</keyword>
  302.         <keyword>INPUT</keyword>
  303.         <keyword>INTENSE</keyword>
  304.         <keyword>INTERNATIONAL</keyword>
  305.         <keyword>INVERSE</keyword>
  306.         <keyword>IS</keyword>
  307.         <keyword>ISNOT</keyword>
  308.         <keyword>JOIN</keyword>
  309.         <keyword>LABEL</keyword>
  310.         <keyword>LDFLAGS</keyword>
  311.         <keyword>LE</keyword>
  312.         <keyword>LET</keyword>
  313.         <keyword>LIBRARY</keyword>
  314.         <keyword>LMODE</keyword>
  315.         <keyword>LOCAL</keyword>
  316.         <keyword>LOOKUP</keyword>
  317.         <keyword>LT</keyword>
  318.         <keyword>MAP</keyword>
  319.         <keyword>MAGENTA</keyword>
  320.         <keyword>MAKEDIR</keyword>
  321.         <keyword>MEMREWIND</keyword>
  322.         <keyword>MEMSTREAM</keyword>
  323.         <keyword>MEMTYPE</keyword>
  324.         <keyword>MONITOR</keyword>
  325.         <keyword>MULTICAST</keyword>
  326.         <keyword>NE</keyword>
  327.         <keyword>NETWORK</keyword>
  328.         <keyword>NEXT</keyword>
  329.         <keyword>NORMAL</keyword>
  330.         <keyword>OFF</keyword>
  331.         <keyword>OFFSET</keyword>
  332.         <keyword>OMODE</keyword>
  333.         <keyword>ON</keyword>
  334.         <keyword>OPEN</keyword>
  335.         <keyword>OPTION</keyword>
  336.         <keyword>OPTIONS</keyword>
  337.         <keyword>OTHER</keyword>
  338.         <keyword>PARSE</keyword>
  339.         <keyword>POKE</keyword>
  340.         <keyword>PRAGMA</keyword>
  341.         <keyword>PRINT</keyword>
  342.         <keyword>PROPER</keyword>
  343.         <keyword>PROTO</keyword>
  344.         <keyword>PULL</keyword>
  345.         <keyword>PUSH</keyword>
  346.         <keyword>PUTBYTE</keyword>
  347.         <keyword>PUTLINE</keyword>
  348.         <keyword>QUOTED</keyword>
  349.         <keyword>RE</keyword>
  350.         <keyword>READING</keyword>
  351.         <keyword>READ</keyword>
  352.         <keyword>READLN</keyword>
  353.         <keyword>READWRITE</keyword>
  354.         <keyword>RECEIVE</keyword>
  355.         <keyword>RECORD</keyword>
  356.         <keyword>RECURSIVE</keyword>
  357.         <keyword>RED</keyword>
  358.         <keyword>REDIM</keyword>
  359.         <keyword>RELATE</keyword>
  360.         <keyword>RENAME</keyword>
  361.         <keyword>REPEAT</keyword>
  362.         <keyword>RESET</keyword>
  363.         <keyword>RESIZE</keyword>
  364.         <keyword>RESTORE</keyword>
  365.         <keyword>RESUME</keyword>
  366.         <keyword>RETURN</keyword>
  367.         <keyword>REWIND</keyword>
  368.         <keyword>SAVE</keyword>
  369.         <keyword>SCROLL</keyword>
  370.         <keyword>SCTP</keyword>
  371.         <keyword>SEED</keyword>
  372.         <keyword>SEEK</keyword>
  373.         <keyword>SELECT</keyword>
  374.         <keyword>SEND</keyword>
  375.         <keyword>SERVER</keyword>
  376.         <keyword>SETENVIRON</keyword>
  377.         <keyword>SETSERIAL</keyword>
  378.         <keyword>SIGNAL</keyword>
  379.         <keyword>SIZE</keyword>
  380.         <keyword>SLEEP</keyword>
  381.         <keyword>SOCKET</keyword>
  382.         <keyword>SORT</keyword>
  383.         <keyword>SPEED</keyword>
  384.         <keyword>SPLIT</keyword>
  385.         <keyword>START</keyword>
  386.         <keyword>STARTPOINT</keyword>
  387.         <keyword>STATIC</keyword>
  388.         <keyword>STEP</keyword>
  389.         <keyword>STOP</keyword>
  390.         <keyword>SUB</keyword>
  391.         <keyword>SWAP</keyword>
  392.         <keyword>SYSTEM</keyword>
  393.         <keyword>TCP</keyword>
  394.         <keyword>TEXTDOMAIN</keyword>
  395.         <keyword>THEN</keyword>
  396.         <keyword>TO</keyword>
  397.         <keyword>TRACE</keyword>
  398.         <keyword>TRAP</keyword>
  399.         <keyword>TYPE</keyword>
  400.         <keyword>UDP</keyword>
  401.         <keyword>UNTIL</keyword>
  402.         <keyword>UP</keyword>
  403.         <keyword>USEC</keyword>
  404.         <keyword>USEH</keyword>
  405.         <keyword>UTF8</keyword>
  406.         <keyword>VAR</keyword>
  407.         <keyword>VARTYPE</keyword>
  408.         <keyword>WEND</keyword>
  409.         <keyword>WHENCE</keyword>
  410.         <keyword>WHILE</keyword>
  411.         <keyword>WHITE</keyword>
  412.         <keyword>WITH</keyword>
  413.         <keyword>WRITELN</keyword>
  414.         <keyword>WRITING</keyword>
  415.         <keyword>YELLOW</keyword>
  416.     </context>
  417.  
  418.     <context id="strfunction" style-ref="function">
  419.         <match extended="true">
  420.             \bCHOP\$|\bCHR\$|\bCONCAT\$|\bCURDIR\$|\bERR\$|\bEXEC\$|\bEXTRACT\$|\bFILL\$|\bGETENVIRON\$|\bGETPEER\$|\bHOSTNAME\$|\bHEX\$|\bHOST\$
  421.                 |\bIIF\$|\bINTL\$|\bLCASE\$|\bLEFT\$|\bMAX\$|\bMID\$|\bMIN\$|\bMONTH\$|\bNNTL\$|\bOS\$|\bREPLACE\$|\bREVERSE\$|\bRIGHT\$|\bSPC\$|\bSTR\$
  422.                 |\bTAB\$|\bTYPEOF\$|\bUCASE\$|\bWEEKDAY\$|\bREALPATH\$|\bBASENAME\$|\bDIRNAME\$|\bRUN\$|\bINBETWEEN\$|\bTOKEN\$|\bLOAD\$|\bOUTBETWEEN\$
  423.                 |\bFLATTEN\$|\bINSERT\$|\bBIN\$|\bEXCHANGE\$|\bCHANGE\$|\bUNFLATTEN\$|\bUNIQ\$|\bSORT\$|\bREV\$|\bDELIM\$|\bHEAD\$|\bTAIL\$|\bAPPEND\$
  424.                 |\bDEL\$|\bCUT\$|\bALIGN\$|\bUTF8\$|\bPROPER\$|\bROTATE\$|\bLAST\$|\bFIRST\$|\bME\$|\bEXPLODE\$|\bOBTAIN\$|\bB64ENC\$|\bB64DEC\$|\bMERGE\$
  425.         </match>
  426.     </context>
  427.  
  428.     <context id="types" style-ref="type">
  429.         <keyword>NUMBER</keyword>
  430.         <keyword>STRING</keyword>
  431.         <keyword>FLOATING</keyword>
  432.         <keyword>FILE\*</keyword>
  433.         <keyword>int</keyword>
  434.         <keyword>double</keyword>
  435.         <keyword>float</keyword>
  436.         <keyword>long</keyword>
  437.         <keyword>char</keyword>
  438.         <keyword>short</keyword>
  439.         <keyword>void</keyword>
  440.         <keyword>signed</keyword>
  441.         <keyword>unsigned</keyword>
  442.         <keyword>static</keyword>
  443.     </context>
  444.  
  445.     <context id="special-constants" style-ref="special-constant">
  446.         <match extended="true">
  447.             \bMAXRANDOM\b|\bNL\$|\bCR\$|\bEL\$|\bCL\$|\bPI\b|\bREGLEN\b|\bRETVAL\b|\bLINENO\b|\bVERSION\$|\bARGUMENT\$|\bSOURCE\$|\bNULL\b
  448.         </match>
  449.     </context>
  450.  
  451.     <context id="boolean" style-ref="boolean">
  452.         <keyword>FALSE</keyword>
  453.         <keyword>TRUE</keyword>
  454.     </context>
  455.  
  456.     <context id="operators" style-ref="operator" extend-parent="false">
  457.       <match>[-%\+/\*\=|&amp;&lt;&gt;()]</match>
  458.     </context>
  459.  
  460.     <context id="wrapper" style-ref="wrapperfunc">
  461.         <keyword>INIT</keyword>
  462.         <keyword>HUGOPTIONS</keyword>
  463.         <keyword>PROPERTY</keyword>
  464.         <keyword>GETPROPERTY</keyword>
  465.         <keyword>SETPROPERTY</keyword>
  466.         <keyword>QUIT</keyword>
  467.         <keyword>DRAW</keyword>
  468.         <keyword>HIDE</keyword>
  469.         <keyword>SHOW</keyword>
  470.         <keyword>WINDOW</keyword>
  471.         <keyword>DISPLAY</keyword>
  472.         <keyword>REGISTER</keyword>
  473.         <keyword>METHOD</keyword>
  474.         <keyword>TEXT</keyword>
  475.         <keyword>GET</keyword>
  476.         <keyword>SET</keyword>
  477.         <keyword>NOTEBOOK</keyword>
  478.         <keyword>BUTTON</keyword>
  479.         <keyword>STOCK</keyword>
  480.         <keyword>TOGGLE</keyword>
  481.         <keyword>CHECK</keyword>
  482.         <keyword>RADIO</keyword>
  483.         <keyword>ENTRY</keyword>
  484.         <keyword>PASSWORD</keyword>
  485.         <keyword>MARK</keyword>
  486.         <keyword>COMBO</keyword>
  487.         <keyword>HSEPARATOR</keyword>
  488.         <keyword>VSEPARATOR</keyword>
  489.         <keyword>FRAME</keyword>
  490.         <keyword>EDIT</keyword>
  491.         <keyword>LIST</keyword>
  492.         <keyword>MSGDIALOG</keyword>
  493.         <keyword>FILEDIALOG</keyword>
  494.         <keyword>SPIN</keyword>
  495.         <keyword>IMAGE</keyword>
  496.         <keyword>CANVAS</keyword>
  497.         <keyword>CLIPBOARD</keyword>
  498.         <keyword>PROGRESSBAR</keyword>
  499.         <keyword>CALLBACK</keyword>
  500.         <keyword>CALLBACKX</keyword>
  501.         <keyword>MOUSE</keyword>
  502.         <keyword>CIRCLE</keyword>
  503.         <keyword>PIXEL</keyword>
  504.         <keyword>LINE</keyword>
  505.         <keyword>SQUARE</keyword>
  506.         <keyword>OUT</keyword>
  507.         <keyword>PICTURE</keyword>
  508.         <keyword>ATTACH</keyword>
  509.         <keyword>TIMEOUT</keyword>
  510.         <keyword>FONT</keyword>
  511.         <keyword>DISABLE</keyword>
  512.         <keyword>ENABLE</keyword>
  513.         <keyword>FOCUS</keyword>
  514.         <keyword>UNFOCUS</keyword>
  515.         <keyword>SCREENSIZE</keyword>
  516.         <keyword>KEY</keyword>
  517.         <keyword>RESETKEY</keyword>
  518.         <keyword>WIDGET</keyword>
  519.         <keyword>SYNC</keyword>
  520.         <keyword>INIT</keyword>
  521.         <keyword>HSLIDER</keyword>
  522.         <keyword>VSLIDER</keyword>
  523.         <keyword>ISPRIME</keyword>
  524.         <keyword>PRECISION</keyword>
  525.         <keyword>FCOMPARE</keyword>
  526.         <keyword>BACKEND</keyword>
  527.         <keyword>FULLSCREEN</keyword>
  528.         <keyword>ARC</keyword>
  529.         <keyword>TRIANGLE</keyword>
  530.         <keyword>POLYGON</keyword>
  531.         <keyword>QBEZIER</keyword>
  532.         <keyword>CBEZIER</keyword>
  533.         <keyword>PAINT</keyword>
  534.         <keyword>GETINK</keyword>
  535.         <keyword>FLIP</keyword>
  536.         <keyword>GRID</keyword>
  537.         <keyword>INK</keyword>
  538.         <keyword>PEN</keyword>
  539.         <keyword>ROTATION</keyword>
  540.         <keyword>SCALE</keyword>
  541.         <keyword>MOVE</keyword>
  542.         <keyword>CLS</keyword>
  543.         <keyword>WAITKEY</keyword>
  544.         <keyword>PENUP</keyword>
  545.         <keyword>PENDOWN</keyword>
  546.         <keyword>PENXY</keyword>
  547.         <keyword>PENTYPE</keyword>
  548.         <keyword>TURNRIGHT</keyword>
  549.         <keyword>TURN</keyword>
  550.         <keyword>TURNLEFT</keyword>
  551.         <keyword>RESETANGLE</keyword>
  552.         <keyword>LOADFONT</keyword>
  553.         <keyword>WIDTH</keyword>
  554.         <keyword>HEIGHT</keyword>
  555.         <keyword>REFRESH</keyword>
  556.     </context>
  557.  
  558.     <context id="wrapperstr" style-ref="wrapperfunc">
  559.         <match extended="true">
  560.             \bGRAB\$|\bGETCOLOR\$|\bHUGLIB\$|\bHUGVERSION\$|\bADD\$|\bSUBSTRACT\$|\bMULTIPLY\$|\bDIVIDE\$|\bMODULO\$|\bPOWER\$|\bSQUARE\$|\bROOT\$|\bFADD\$|\bFSUBSTRACT\$|\bFMULTIPLY\$|\bFDIVIDE\$|\bFPOWER\$|\bFIBONACCI\$|\bFACTORIAL\$|\bNEXTPRIME\$|\bFSQUARE\$|\bGCD\$
  561.         </match>
  562.     </context>
  563.  
  564.     <context id="bacon">
  565.         <include>
  566.             <context ref="def:shebang" style-ref="shebang"/>
  567.             <context ref="line-comment"/>
  568.             <context ref="old-style-comment"/>
  569.             <context ref="multiline-comment"/>
  570.             <context ref="string"/>
  571.             <context ref="strfunction"/>
  572.             <context ref="function"/>
  573.             <context ref="keywords"/>
  574.             <context ref="special-constants"/>
  575.             <context ref="types"/>
  576.             <context ref="boolean"/>
  577.             <context ref="operators"/>
  578.             <context ref="wrapper"/>
  579.             <context ref="wrapperstr"/>
  580.         </include>
  581.     </context>
  582.  
  583. </definitions>
  584.  
  585. </language>
  586.  
Title: Re: SB π
Post by: John on April 02, 2019, 10:33:45 PM
I found a C example of accessing the relative humidity, temperature and hPa pressure sensors. I'm not sure yet if it will work with the Sense HAT emulator or not. To me it looks like opening a file link to the /dev/i2c-1 device interface and reading and writing up to 16 bytes of data.

Writting a Sense HAT API in the language of choice (must run on RPi) might be a good code challenge.

basicsensor.c
Code: C
  1. /*
  2. gcc -g -O -Wall -o basicsensor basicsensor.c
  3.  
  4. This program is based on experix, an experiment and process control interface.
  5. */
  6. #include <stdio.h>
  7. #include <fcntl.h>
  8. #include <time.h>
  9. #include <unistd.h>
  10. #include <sys/types.h>
  11. #include <sys/stat.h>
  12. #include <sys/ioctl.h>
  13. #include <stdlib.h>
  14. #include <asm/types.h>
  15. #include "HTS221.h"   // HTS221 relative humidity and temperature sensor
  16. #include "LPS25H.h"   // LPS25H MEMS 260-1260 hPa pressure sensor
  17.  
  18. // averaging mode and output rate definitions for HTS221 and LPS25H
  19. #define LPS25HifAVGP 3
  20. #define LPS25HifODR 3
  21. #define HTS221ifODR 3
  22. #define HTS221ifAVGT 3
  23. #define HTS221ifAVGH 3
  24.  
  25. // definitions for i2c-dev
  26. #define DEVPATH_I2C     "/dev/i2c-1"  // the device file
  27. #define I2C_SLAVE       0x0703        // ioctl:  Use this slave address
  28.  
  29. __s16 HTS221_T_OUT, HTS221_H_OUT;
  30. __s32 LPS25H_P_OUT;
  31. __s16 H0_T0_OUT = 0;
  32. __s16 H1_T0_OUT = 0;
  33. __s16 T0_OUT = 0;
  34. __s16 T1_OUT = 0;
  35. float H0_rH, H1_rH;
  36. float T0_degC, T1_degC;
  37. __u8 LPS25H_status, LPS25H_fifo_status, HTS221_status;
  38. char i2cDp[] = DEVPATH_I2C;
  39.  
  40. float P_LPS25H, T_HTS221, H_HTS221;
  41. void show_readings() {
  42.   P_LPS25H = (float)(LPS25H_P_OUT) / 4096.0f;
  43.   T_HTS221 = T0_degC + (((float)(HTS221_T_OUT)-T0_OUT)/(T1_OUT-T0_OUT))*(T1_degC-T0_degC);
  44.   H_HTS221 = H0_rH + (((float)(HTS221_H_OUT)-H0_T0_OUT)/(H1_T0_OUT-H0_T0_OUT))*(H1_rH-H0_rH);
  45.  
  46.   printf( "P_LPS25H  mbar      T_HTS221    deg C     H_HTS221    rH\n" );
  47.   printf( "0x%-8.04x%+-10.5g0x%-10.04x%+-10.5g0x%-10.04x%+-10.5g\n",
  48.          (__u32)(LPS25H_P_OUT), P_LPS25H, (__u16)(HTS221_T_OUT), T_HTS221,
  49.          (__u16)(HTS221_H_OUT), H_HTS221 );
  50. }
  51.  
  52. int main() {
  53.   int i2c, res;
  54.   unsigned char buf[16];
  55.   unsigned char HTS221cal[16];
  56.   __u16 T0_degC_x8;
  57.   __u16 T1_degC_x8;
  58.   __u8 H0_rH_x2;
  59.   __u8 H1_rH_x2;
  60.  
  61.   // open the i2c device on raspberry pi
  62.   i2c = open( i2cDp, O_RDWR );
  63.   if ( i2c == -1 ) {
  64.     perror( "open i2c" );
  65.     return 1;
  66.   }
  67.  
  68.   // discover LPS25H
  69.   res = ioctl( i2c, I2C_SLAVE, LPS25H_SAD );
  70.   buf[0] = LPS25H_WHO_AM_I;
  71.   res = write( i2c, buf, 1 );
  72.   if ( res == -1 ) {
  73.     perror( "write i2c" );
  74.     return 1;
  75.   }
  76.   res = read( i2c, buf, 1 );
  77.   if ( res != 1 ) {
  78.     if ( res == -1 ) perror( "read i2c" );
  79.     else printf( "read i2c returns %d\n", res );
  80.     return 1;
  81.   }
  82.   if ( buf[0] != LPS25H_who_am_i ) {
  83.     printf( "expect LPS25H id = 0x%x, get 0x%x\n", LPS25H_who_am_i, buf[0] );
  84.     return 1;
  85.   }
  86.   // Set up for temperature measurements using the LPS25H
  87.   // Set LPS25H_CTRL_REG1 following usage in RTIMULibDrive11
  88.   buf[0] = LPS25H_CTRL_REG1;
  89.   buf[1] = LPS25H_CTRL_REG1_PD_if(1) |      // power up
  90.          LPS25H_CTRL_REG1_ODR_if(LPS25HifODR) | // output data rate
  91.          LPS25H_CTRL_REG1_DIFF_EN_if(0) |   // disable differential pressure
  92.          LPS25H_CTRL_REG1_BDU_if(1) |       // enable block update
  93.          LPS25H_CTRL_REG1_RESET_AZ_if(0) |  // do not auto-zero
  94.          LPS25H_CTRL_REG1_SIM_if(0);        // SPI mode (irrelevant for i2c)
  95.   res = write( i2c, buf, 2 );
  96.   if ( res != 2 ) {
  97.     perror( "i2c write LPS25H" );
  98.     return 1;
  99.   }
  100.   /* Set pressure averaging modes: internal averaging numbers
  101.                                        for mode = 0,  1,   2,   3
  102.   LPS25HifAVGP      pressure averaging number     8, 32, 128, 512  */
  103.   buf[0] = LPS25H_RES_CONF;
  104.   buf[1] = LPS25H_AV_CONF_AVGP_if(LPS25HifAVGP);
  105.   res = write( i2c, buf, 2 );
  106.   /* Set FIFO mode. (The FIFO holds pressure data so this should not make a
  107.   difference for temperature.) */
  108.   buf[0] = LPS25H_FIFO_CTRL;
  109.   buf[1] = LPS25H_FIFO_CTRL_F_MODE_if(6) |    // running average
  110.            LPS25H_FIFO_CTRL_WTM_POINT_if(1);  // average 2 samples
  111.   res = write( i2c, buf, 2 );
  112.   // Set LPS25H_CTRL_REG2 following usage in RTIMULibDrive11
  113.   buf[0] = LPS25H_CTRL_REG2;
  114.   buf[1] = LPS25H_CTRL_REG2_BOOT_if(0) |      // no refresh registers from flash
  115.            LPS25H_CTRL_REG2_FIFO_EN_if(1) |   // enable FIFO
  116.            LPS25H_CTRL_REG2_WTM_EN_if(0) |    // no enable FIFO watermark
  117.            LPS25H_CTRL_REG2_FIFO_MEAN_DEC_if(0) | // no enable 1 Hz ODR decim.
  118.            LPS25H_CTRL_REG2_SWRESET_if(0) |   // no software reset (with BOOT=1)
  119.            LPS25H_CTRL_REG2_AUTO_ZERO_if(0) | // no copy PRESS_OUT to REF_P
  120.            LPS25H_CTRL_REG2_ONE_SHOT_if(0);   // no do one-shot here
  121.   /* LPS25H_CTRL_REG3, LPS25H_CTRL_REG4, LPS25H_INT_CFG are irrelevant since
  122.      interrupts are not being used. */
  123.    // discover HTS221
  124.    res = ioctl( i2c, I2C_SLAVE, HTS221_SAD );
  125.    buf[0] = HTS221_WHO_AM_I;
  126.    res = write( i2c, buf, 1 );
  127.    if ( res != 1 ) {
  128.      perror( "i2c write HTS221" );
  129.      return 1;
  130.    }
  131.    res = read( i2c, buf, 1 );
  132.    if ( res != 1 ) {
  133.      if ( res == -1 ) perror( "read i2c" );
  134.      else printf( "read i2c returns %d\n", res );
  135.      return 1;
  136.    }
  137.    if ( buf[0] != HTS221_who_am_i ) {
  138.      printf( "expect HTS221 id = 0x%x, get 0x%x\n", HTS221_who_am_i, buf[0] );
  139.      return 1;
  140.    }
  141.    // Set up for temperature measurements using the HTS221
  142.    // Set HTS221_CTRL_REG1 following usage in RTIMULibDrive11
  143.    buf[0] = HTS221_CTRL_REG1;                                         //Drive11
  144.    buf[1] = HTS221_CTRL_REG1_PD_if(1) |            // power up             1
  145.             HTS221_CTRL_REG1_BDU_if(1) |           // enable block update  1
  146.             HTS221_CTRL_REG1_ODR_if(HTS221ifODR);  // output data rate     3
  147.    res = write( i2c, buf, 2 );
  148.    /* Set temperature and humidity averaging modes: internal averaging numbers
  149.                                     for mode = 0, 1,  2,  3,  4,   5,   6,   7
  150.    HTS221ifAVGH  humidity averaging number     4, 8, 16, 32, 64, 128, 256, 512
  151.    HTS221ifAVGT  temperature averaging number  2, 4,  8, 16, 32,  64, 128, 256 */
  152.    buf[0] = HTS221_AV_CONF;                                           //Drive11
  153.    buf[1] = HTS221_AV_CONF_AVGT_if(HTS221ifAVGT) |                    //   3
  154.             HTS221_AV_CONF_AVGH_if(HTS221ifAVGH);                     //   3
  155.    res = write( i2c, buf, 2 );
  156.    /* Read the calibration registers and calculate conversion coefficients.
  157.    See datasheet tables 19 and 20. */
  158.    buf[0] = HTS221_CAL_H0_rH_x2 | HTS221_reg_auto;
  159.    res = write( i2c, buf, 1 );
  160.    res  = read( i2c, HTS221cal, 16 );
  161.    if ( res != 16 ) {
  162.      if ( res == -1 ) perror( "HTS221_CAL_H0_rH_x2" );
  163.      else printf( "read 16 at HTS221_CAL_H0_rH_x2 returns %d\n", res );
  164.    }
  165.  
  166.    T0_degC_x8 = (((__u16)HTS221cal[5] & 0x3 ) << 8) | (__u16)HTS221cal[2];
  167.    T1_degC_x8 = (((__u16)HTS221cal[5] & 0xc ) << 6) | (__u16)HTS221cal[3];
  168.    T0_OUT = ((__s16*)(HTS221cal))[6];
  169.    T1_OUT = ((__s16*)(HTS221cal))[7];
  170.    H0_T0_OUT = ((__s16*)(HTS221cal))[3];
  171.    H1_T0_OUT = ((__s16*)(HTS221cal))[5];
  172.    H0_rH_x2 = ((__u8*)(HTS221cal))[0];
  173.    H1_rH_x2 = ((__u8*)(HTS221cal))[1];
  174.    T0_degC = (float)(T0_degC_x8) / 8.0f;
  175.    T1_degC = (float)(T1_degC_x8) / 8.0f;
  176.    H0_rH = (float)(H0_rH_x2) / 2.0f;
  177.    H1_rH = (float)(H1_rH_x2) / 2.0f;
  178.  
  179.    // get a LPS25H pressure sample
  180.    res = ioctl( i2c, I2C_SLAVE, LPS25H_SAD );
  181.    buf[0] = LPS25H_STATUS_REG;
  182.    res = write( i2c, buf, 1 );
  183.    res = read( i2c, buf, 2 );
  184.    LPS25H_status = buf[0];
  185.    buf[0] = LPS25H_FIFO_STATUS;
  186.    res = write( i2c, buf, 1 );
  187.    res = read( i2c, buf, 2 );
  188.    LPS25H_fifo_status = buf[0];
  189.    buf[0] = LPS25H_PRESS_POUT|LPS25H_reg_auto;
  190.    res = write( i2c, buf, 1 );
  191.    res = read( i2c, buf, 3 ); // read registers at 0x28, 0x29, 0x2a
  192.    LPS25H_P_OUT = (((__s32)(buf[2])) << 16) | (((__s32)(buf[1])) << 8) | (((__s32)(buf[0])));
  193.    // get a HTS221 humidity sample
  194.    res = ioctl( i2c, I2C_SLAVE, HTS221_SAD );
  195.    buf[0] = HTS221_STATUS_REG;
  196.    res = write( i2c, buf, 1 );
  197.    res = read( i2c, buf, 2 );
  198.    HTS221_status = buf[0];
  199.    buf[0] = HTS221_HUMIDITY_OUT | HTS221_reg_auto;
  200.    res = write( i2c, buf, 1 );
  201.    res = read( i2c, buf, 2 );
  202.    HTS221_H_OUT = (((__s16)buf[1]) << 8) | (__s16)buf[0];
  203.    buf[0] = HTS221_TEMP_OUT | HTS221_reg_auto;
  204.    res = write( i2c, buf, 1 );
  205.    res = read( i2c, buf, 2 );
  206.    HTS221_T_OUT = (((__s16)buf[1]) << 8) | (__s16)buf[0];
  207.  
  208.    show_readings();
  209.  
  210.    close(i2c);
  211.    return 0;
  212. }
  213.  

HTS221.h - relative humidity and temperature sensor
Code: C
  1. /*
  2. This file is part of experix, an experiment and process control interface.
  3. Copyright (C) 2004-2016 William Bayard McConnaughey
  4.  
  5. experix is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the Licence, or
  8. (at your option) any later version.
  9.  
  10. experix is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public Licence for more details.
  14.  
  15. You should have received a copy of the GNU General Public Licence
  16. along with experix.  If not, see <http://www.gnu.org/licenses/>.
  17.  
  18. Programming definitions for the HTS221 capacitive digital sensor for
  19. relative humidity and temperature (STMicroelectronics NV)
  20. Reference: datasheet DM00116291.pdf (October 2015), www.st.com
  21. Very terse comments are provided in this file. See explanations in the
  22. datasheet. This header is specialized for Raspberry Pi sense-hat usage.
  23. Names used are mostly composed by prepending "HTS221_" on the register and
  24. bitfield names used in the datasheet. Terms in ALL CAPS are the register
  25. designations; those with lower-case letters are data values or bitfield
  26. macros.
  27. Registers marked with the comment "//2" are register pairs, where the
  28. designation applies to the least significant byte and the high byte is
  29. addressed by adding "+1". (The data sheet uses two definitions with "_L"
  30. and "_H" on the end).
  31. For bitfields we are using function-style definitions. The ones ending in
  32. "_ef(v)" are for extracting field values from a register value, and the
  33. "_if(f)" ones are for inserting fields into a register value. Example: to make
  34. the HTS221_AV_CONF setting for AVGH=6 and AVGT=2, use this expression:
  35. HTS221_AV_CONF_AVGT_if(2)|HTS221_AV_CONF_AVGH_if(6)
  36. Field length in bits is shown by comments such as  //2b
  37. Note that these macros do not check for inappropriate submitted values.  
  38. Note well, regarding register addresses not mentioned herein: from the
  39. datasheet, "Registers marked as Reserved must not be changed. Writing to
  40. those registers may cause permanent damage to the device."
  41. */
  42. /* Notes on Raspberry Pi sense-hat use
  43. CS (pin 6) is high: I2C interface is used, with GPIO3 to SCL/SPC (pin 2) and
  44. GPIO2 to SDA/SDI/SDO (pin 4). DRDY (pin 3) goes only to a test-point.
  45. */
  46. #define HTS221_SAD          0x5f  // slave address
  47. #define HTS221_WHO_AM_I     0x0f  // read this to get--
  48. #define HTS221_who_am_i     0xbc  //   this device identifier
  49.  
  50. #define HTS221_reg_auto     0x80  // OR with register addr. to auto-advance
  51.  
  52. // humidity and temerature resolution mode:  see datasheet table 16
  53. #define HTS221_AV_CONF      0x10
  54. #define HTS221_AV_CONF_AVGT_if(f) ((f)<<3)      //3b temperature avg. mode
  55. #define HTS221_AV_CONF_AVGH_if(f) (f)           //3b humidity avg. mode
  56.  
  57. #define HTS221_CTRL_REG1    0x20
  58. #define HTS221_CTRL_REG1_PD_if(f) ((f)<<7)      //1b 0= powerdown, 1= active
  59. #define HTS221_CTRL_REG1_BDU_if(f) ((f)<<2)     //1b 0= continuous update
  60. #define HTS221_CTRL_REG1_ODR_if(f) (f)          //2b output data rate
  61.  
  62. #define HTS221_CTRL_REG2    0x21
  63. #define HTS221_CTRL_REG2_BOOT_if(f) ((f)<<7)    //1b 1= reboot memory content
  64. #define HTS221_CTRL_REG2_HEATER_if(f) ((f)<<1)  //1b 1= enable heater
  65. #define HTS221_CTRL_REG2_ONE_SHOT_if(f) (f)     //1b 1= start for a new dataset
  66.  
  67. // note: DRDY pin is not being used in the sense-hat
  68. #define HTS221_CTRL_REG3    0x22
  69. #define HTS221_CTRL_REG3_DRDY_H_L_if(f) ((f)<<7) //1b DRDY active hi/lo
  70. #define HTS221_CTRL_REG3_PP_OD_if(f) ((f)<<6)    //1b push-pull / open-drain
  71. #define HTS221_CTRL_REG3_DRDY_EN_if(f) ((f)<<2)  //1b enable DRDY
  72.  
  73. #define HTS221_STATUS_REG   0x27
  74. #define HTS221_STATUS_REG_H_DA_ef(v) (((v)>>1)&1) //1b new humidity avail.
  75. #define HTS221_STATUS_REG_T_DA_ef(v) ((v)&1)      //1b new temperature avail.
  76.  
  77. #define HTS221_HUMIDITY_OUT 0x28  //2  humidity data out
  78. #define HTS221_TEMP_OUT     0x2a  //2  temperature data out
  79.  
  80. /* See datasheet discussion on use of calibration registers and values.
  81. DO NOT MODIFY these registers. Names are made by prepending "HTS221_CAL_"
  82. onto the register names in table 19, except where that would not be usable. */
  83. #define HTS221_CAL_H0_rH_x2   0x30
  84. #define HTS221_CAL_H1_rH_x2   0x31
  85. #define HTS221_CAL_T0_degC_x8 0x32
  86. #define HTS221_CAL_T1_degC_x8 0x33
  87. #define HTS221_CAL_T1_T0_msb  0x35
  88. #define HTS221_CAL_H0_T0_OUT  0x36  //2
  89. #define HTS221_CAL_H1_T0_OUT  0x3a  //2
  90. #define HTS221_CAL_T0_OUT     0x3c  //2
  91. #define HTS221_CAL_T1_OUT     0x3e  //2
  92.  

LPS25H.h - hPa pressure sensor
Code: C
  1. /*
  2. This file is part of experix, an experiment and process control interface.
  3. Copyright (C) 2004-2016 William Bayard McConnaughey
  4.  
  5. experix is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the Licence, or
  8. (at your option) any later version.
  9.  
  10. experix is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public Licence for more details.
  14.  
  15. You should have received a copy of the GNU General Public Licence
  16. along with experix.  If not, see <http://www.gnu.org/licenses/>.
  17.  
  18. Programming definitions for the LPS25H MEMS 260-1260 hPa pressure sensor
  19. (STMicroelectronics NV)
  20. Reference: datasheet DM00066332.pdf (January 2014), www.st.com
  21. Very terse comments are provided in this file. See explanations in the
  22. datasheet. This header is specialized for Raspberry Pi sense-hat usage.
  23. Names used are mostly composed by prepending "LPS25H_" on the register and
  24. bitfield names used in the datasheet. Terms in ALL CAPS are the register
  25. designations; those with lower-case letters are data values or bitfield
  26. macros.
  27. Registers marked with the comment "//2" are register pairs, where the
  28. designation applies to the least significant byte and the high byte is
  29. addressed by adding "+1". Likewise, "//3" signifies a register triple. (The
  30. data sheet uses two or three definitions with "_XL", "_L" and "_H" on the end).
  31. For bitfields we are using function-style definitions. The ones ending in
  32. "_ef(v)" are for extracting field values from a register value, and the "_if(f)"
  33. ones are for inserting field values into a register value. Example: to make
  34. the LPS25H_AV_CONF setting for AVGP=3 and AVGT=2, use this expression:
  35. LPS25H_AV_CONF_AVGT_if(2)|LPS25H_AV_CONF_AVGP_if(3)
  36. Field length in bits is shown by comments such as  //2b
  37. Note that these macros do not check for inappropriate submitted values.  
  38. Note well, regarding register addresses not mentioned herein: from the
  39. datasheet, "Registers marked as Reserved must not be changed. The Writing to
  40. those registers may cause permanent damages to the device. The content of the
  41. registers that are loaded at boot should not be changed. They contain the
  42. factory calibration values. Their content is automatically restored when the
  43. device is powered-up."
  44. */
  45. /* Notes on Raspberry Pi sense-hat use
  46. CS (pin 6) is high: I2C interface is used, with GPIO3 to SCL/SPC (pin 2) and
  47. GPIO2 to SDA/SDI/SDO (pin 4). INT1 (pin 7) goes only to a test-point. SDO/SA0
  48. (pin 5) is grounded, so LSB of device address is 0.
  49. */
  50. #define LPS25H_SAD          0x5c // slave address for device on sense-hat
  51. #define LPS25H_WHO_AM_I     0x0f  // read this to get--
  52. #define LPS25H_who_am_i     0xbd  //   this device identifier
  53.  
  54. #define LPS25H_reg_auto     0x80  // OR with register addr. to auto-advance
  55.  
  56. #define LPS25H_REF_P        0x08  //3  Reference pressure
  57.  
  58. #define LPS25H_RES_CONF     0x10  // Pressure and temperature resolution mode
  59. #define LPS25H_AV_CONF_AVGT_if(f) ((f)<<2)   //2b temperature. averaging mode
  60. #define LPS25H_AV_CONF_AVGP_if(f) (f)        //2b pressure averaging mode
  61.  
  62. #define LPS25H_CTRL_REG1    0x20
  63. #define LPS25H_CTRL_REG1_PD_if(f)       ((f)<<7) //1b powerdown:  1= device active
  64. #define LPS25H_CTRL_REG1_ODR_if(f)      ((f)<<4) //3b output data rate (table 18)
  65. #define LPS25H_CTRL_REG1_DIFF_EN_if(f)  ((f)<<3) //1b enable diff. pressure
  66. #define LPS25H_CTRL_REG1_BDU_if(f)      ((f)<<2) //1b block data update
  67. #define LPS25H_CTRL_REG1_RESET_AZ_if(f) ((f)<<1) //1b pressure reset autozero
  68. #define LPS25H_CTRL_REG1_SIM_if(f)      (f)      //1b SPI serial interface mode
  69.  
  70. #define LPS25H_CTRL_REG2    0x21
  71. #define LPS25H_CTRL_REG2_BOOT_if(f)     ((f)<<7)  //1b refresh registers from flash
  72. #define LPS25H_CTRL_REG2_FIFO_EN_if(f)  ((f)<<6)  //1b enable FIFO
  73. #define LPS25H_CTRL_REG2_WTM_EN_if(f)   ((f)<<5)  //1b enable FIFO watermark
  74. #define LPS25H_CTRL_REG2_FIFO_MEAN_DEC_if(f) ((f)<<4) //1b enable 1 Hz ODR decim.
  75. #define LPS25H_CTRL_REG2_SWRESET_if(f)  ((f)<<2)  //1b software reset (with BOOT=1)
  76. #define LPS25H_CTRL_REG2_AUTO_ZERO_if(f) ((f)<<1) //1b copy PRESS_OUT to REF_P
  77. #define LPS25H_CTRL_REG2_ONE_SHOT_if(f) (f)     //1b with ODR=0, start new conv.
  78.  
  79. #define LPS25H_CTRL_REG3    0x22     // (sense-hat: INT1 not used)
  80. #define LPS25H_CTRL_REG3_INT_H_L_if(f)  ((f)<<7)  //1b interrupt active hi/lo
  81. #define LPS25H_CTRL_REG3_PP_OD_if(f)    ((f)<<6)  //1b push-pull/open-drain select
  82. #define LPS25H_CTRL_REG3_INT1_S_if(f)   (f)     //2b INT pad signal (table 19)
  83.  
  84. #define LPS25H_CTRL_REG4    0x23     // (sense-hat: INT1 not used)
  85. #define LPS25H_CTRL_REG4_P1_EMPTY_if(f) ((f)<<3)  //1b Empty signal on INT1
  86. #define LPS25H_CTRL_REG4_P1_WTM_if(f)   ((f)<<2)  //1b Watermark signal on INT1
  87. #define LPS25H_CTRL_REG4_P1_Overun_if(f) ((f)<<1) //1b Overrun signal on INT1
  88. #define LPS25H_CTRL_REG4_P1_DRDY_if(f)  (f)       //1b Data ready signal on INT1
  89.  
  90. #define LPS25H_INT_CFG      0x24
  91. #define LPS25H_INT_CFG_LIR_if(f)   ((f)<<2) //1b latch int. source into INT_SOURCE
  92. #define LPS25H_INT_CFG_PL_E_if(f)  ((f)<<1) //1b enable int. on diff. press. low
  93. #define LPS25H_INT_CFG_PH_E_if(f)  (f)      //1b enable int. on diff. press. high
  94.  
  95. #define LPS25H_INT_SOURCE   0x25
  96. #define LPS25H_INT_SOURCE_IA_ef(v)   (((v)>>2)&1) //1b interrupt active
  97. #define LPS25H_INT_SOURCE_PL_ef(v)   (((v)>>1)&1) //1b differential pressure low
  98. #define LPS25H_INT_SOURCE_PH_ef(v)   ((v)&1)      //1b differential pressure high
  99.  
  100. #define LPS25H_STATUS_REG   0x27
  101. #define LPS25H_STATUS_REG_P_OR_ef(v) (((v)>>5)&1) //1b pressure data overrun
  102. #define LPS25H_STATUS_REG_T_OR_ef(v) (((v)>>4)&1) //1b temperature data overrun
  103. #define LPS25H_STATUS_REG_P_DA_ef(v) (((v)>>1)&1) //1b pressure data available
  104. #define LPS25H_STATUS_REG_T_DA_ef(v) ((v)&1)      //1b temperature data available
  105.  
  106. #define LPS25H_PRESS_POUT   0x28  //3 pressure data, 3 bytes at 0x28,0x29,0x2a
  107. #define LPS25H_TEMP_OUT     0x2b  //2 temperature data, 2 bytes at 0x2b,0x2c
  108.  
  109. #define LPS25H_FIFO_CTRL    0x2e  // datasheet sec 8: FIFO operating details
  110. #define LPS25H_FIFO_CTRL_F_MODE_if(f)    ((f)<<5) //3b FIFO mode, tables 20,22,23
  111. #define LPS25H_FIFO_CTRL_WTM_POINT_if(f) (f)    //5b watermark select, table 21
  112.  
  113. #define LPS25H_FIFO_STATUS  0x2f
  114. #define LPS25H_FIFO_STATUS_WTM_FIFO_ef(v)   ((v)>>7)     //1b watermark status
  115. #define LPS25H_FIFO_STATUS_FULL_FIFO_ef(v)  (((v)>>6)&1) //1b overrun bit status
  116. #define LPS25H_FIFO_STATUS_EMPTY_FIFO_ef(v) (((v)>>5)&1) //1b empty FIFO
  117. #define LPS25H_FIFO_STATUS_DIFF_POINT_ef(v) ((v)&0x1f)   //5b FIFO data level
  118.  
  119. #define LPS25H_THS_P        0x30  //2  threshold pressure for interrupt
  120. #define LPS25H_RPDS         0x39  //2  pressure offset after soldering
  121.  

It would seem writing a ScriptBasic Sense HAT extension module shouldn't be that hard.
Title: Re: SB π
Post by: John on April 03, 2019, 12:12:28 AM
There doesn't seem to be a /dev/i2c-1 device on my Rpi. I have seen the term fb0 used as a reference to the Sense HAT so I used that. I had the emulator running but it seems to error out trying to read the first sensor. It might be looking for the physical Sense HAT board which hasn't arrived yet.


pi@raspberrypi:~/sbrpi/sensehat $ ./basicsensor
expect LPS25H id = 0xbd, get 0xec
pi@raspberrypi:~/sbrpi/sensehat $


It seems you have to enable the i2c interface via the sudo raspi-config utility and then reboot. I also returned back to the /dev/i2c-1 device reference and now I'm getting and I/O Error which looks promising since I don't have a Sense HAT board installed yet. The emulator doesn't seem to work with the i2c API. Maybe it uses pigio instead?


pi@raspberrypi:~/sbrpi/sensehat $ ./basicsensor
write i2c: Remote I/O error
pi@raspberrypi:~/sbrpi/sensehat $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --                         
pi@raspberrypi:~/sbrpi/sensehat $ i2cdump -y 1 0x68
No size specified (using byte-data access)
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
10: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
20: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
30: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
40: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
50: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
70: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
80: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
90: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
a0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
b0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
c0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
d0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
e0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
f0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
pi@raspberrypi:~/sbrpi/sensehat $



Title: Re: SB π
Post by: John on April 03, 2019, 11:24:42 PM
I discovered the the /dev/i2c-1 device is a serial connection. I thought I would give SB a try connecting directly. It seems to work (no errors) but doesn't return anything either. It looks like I'm not going to make any real progress with this until my Sense HAT board arrives. I've been unable to find a way to use the Sense HAT emulator from C. The other issue is I need to emulate the ioctl() function.

Code: Script BASIC
  1. OPEN "/dev/i2c-1" FOR BINARY AS #1
  2. iout = INPUT(1,1)
  3. PRINT iout,"\n"
  4. CLOSE(1)
  5.  
Title: Re: SB Pi
Post by: AIR on April 04, 2019, 04:22:59 PM
I discovered the the /dev/i2c-1 device is a serial connection. I thought I would give SB a try connecting directly. It seems to work (no errors) but doesn't return anything either. It looks like I'm not going to make any real progress with this until my Sense HAT board arrives. I've been unable to find a way to use the Sense HAT emulator from C. The other issue is I need to emulate the ioctl() function.

Code: Script BASIC
  1. OPEN "/dev/i2c-1" FOR BINARY AS #1
  2. iout = INPUT(1,1)
  3. PRINT iout,"\n"
  4. CLOSE(1)
  5.  

You may want to check out the following: c-sense-hat (https://github.com/davebm1/c-sense-hat)

AIR.
Title: Re: SB π
Post by: John on April 04, 2019, 04:53:22 PM
Awesome!

My Sense HAT is due to arrive on Saturday.

It would be great to find out if the Sense HAT emuator will work with C or not.

Here is another C reference that is helpful.

ic2-dev Info (https://www.kernel.org/doc/Documentation/i2c/dev-interface)
Title: Re: SB π
Post by: John on April 04, 2019, 06:47:48 PM
AIR,

I created a fresh Raspbery PI full NOOBS and tested your latest AppImage release. Everything seems to work great. I didn't install MySQL so that extension module wasn't in the test script set.

I've attached the ScriptBasic examples I used to test the following extension modules.

* cURL
* SQLite
* JSON
* XML
* Regex
* SBT - Threading

Examples not included:

MySQL
ODBC
 
Title: Re: SB π
Post by: John on April 05, 2019, 07:58:12 AM
Quote
It usually says "Illegal instruction" if you try to run a Pi3 binary on a Pi Zero.
Segfault is just a plain bug!

The Pi Zero is ARMv6, whereas the Pi3 models are ARMv8

Code compiled to run under Raspbian on a Pi Zero (or Pi 1) will run on any Pi released so far.

A RPi forum member tried to run the SB AppImage on a RPi Zero and it failed. This is news that not all RPi 's are code compatible.
Title: Re: SB π
Post by: John on April 05, 2019, 03:02:09 PM
Good News!

My Sense HAT board arrived a day early.

I'm looking forward to get ScriptBasic working with it.
Title: Re: SB π
Post by: John on April 05, 2019, 03:39:27 PM
The Sense HAT basicsensor.c program seems to be working.


pi@raspberrypi:~/sbrpi/sensehat $ ./basicsensor
P_LPS25H  mbar      T_HTS221    deg C     H_HTS221    rH
0x2f4800  +756.5    0x005b      +22.403   0xdfeb      +56.698   
pi@raspberrypi:~/sbrpi/sensehat $


This is a Hello World on the LED display.. The same python code works on the emulator and the physical board.

Code: Python
  1. from sense_emu import SenseHat
  2.  
  3. sense = SenseHat()
  4.  
  5. sense.show_message("Hello world!")
  6.  

Changing sense_emu to sense_hat switches between the emulator and the physical board.

i2c-dev.h
Code: C
  1. /*
  2.     i2c-dev.h - i2c-bus driver, char device interface
  3.  
  4.     Copyright (C) 1995-97 Simon G. Vogl
  5.     Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
  6.  
  7.     This program is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation; either version 2 of the License, or
  10.     (at your option) any later version.
  11.  
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  20.     MA 02110-1301 USA.
  21. */
  22.  
  23. #ifndef _LINUX_I2C_DEV_H
  24. #define _LINUX_I2C_DEV_H
  25.  
  26. #include <linux/types.h>
  27. #include <sys/ioctl.h>
  28. #include <stddef.h>
  29.  
  30.  
  31. /* -- i2c.h -- */
  32.  
  33.  
  34. /*
  35.  * I2C Message - used for pure i2c transaction, also from /dev interface
  36.  */
  37. struct i2c_msg {
  38.         __u16 addr;     /* slave address                        */
  39.         unsigned short flags;
  40. #define I2C_M_TEN       0x10    /* we have a ten bit chip address       */
  41. #define I2C_M_RD        0x01
  42. #define I2C_M_NOSTART   0x4000
  43. #define I2C_M_REV_DIR_ADDR      0x2000
  44. #define I2C_M_IGNORE_NAK        0x1000
  45. #define I2C_M_NO_RD_ACK         0x0800
  46.         short len;              /* msg length                           */
  47.         char *buf;              /* pointer to msg data                  */
  48. };
  49.  
  50. /* To determine what functionality is present */
  51.  
  52. #define I2C_FUNC_I2C                    0x00000001
  53. #define I2C_FUNC_10BIT_ADDR             0x00000002
  54. #define I2C_FUNC_PROTOCOL_MANGLING      0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
  55. #define I2C_FUNC_SMBUS_PEC              0x00000008
  56. #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL  0x00008000 /* SMBus 2.0 */
  57. #define I2C_FUNC_SMBUS_QUICK            0x00010000
  58. #define I2C_FUNC_SMBUS_READ_BYTE        0x00020000
  59. #define I2C_FUNC_SMBUS_WRITE_BYTE       0x00040000
  60. #define I2C_FUNC_SMBUS_READ_BYTE_DATA   0x00080000
  61. #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA  0x00100000
  62. #define I2C_FUNC_SMBUS_READ_WORD_DATA   0x00200000
  63. #define I2C_FUNC_SMBUS_WRITE_WORD_DATA  0x00400000
  64. #define I2C_FUNC_SMBUS_PROC_CALL        0x00800000
  65. #define I2C_FUNC_SMBUS_READ_BLOCK_DATA  0x01000000
  66. #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
  67. #define I2C_FUNC_SMBUS_READ_I2C_BLOCK   0x04000000 /* I2C-like block xfer  */
  68. #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK  0x08000000 /* w/ 1-byte reg. addr. */
  69.  
  70. #define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
  71.                              I2C_FUNC_SMBUS_WRITE_BYTE)
  72. #define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \
  73.                                   I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
  74. #define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \
  75.                                   I2C_FUNC_SMBUS_WRITE_WORD_DATA)
  76. #define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
  77.                                    I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
  78. #define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
  79.                                   I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
  80.  
  81. /* Old name, for compatibility */
  82. #define I2C_FUNC_SMBUS_HWPEC_CALC       I2C_FUNC_SMBUS_PEC
  83.  
  84. /*
  85.  * Data for SMBus Messages
  86.  */
  87. #define I2C_SMBUS_BLOCK_MAX     32      /* As specified in SMBus standard */
  88. #define I2C_SMBUS_I2C_BLOCK_MAX 32      /* Not specified but we use same structure */