Author Topic: SB π  (Read 7545 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB Pi
« Reply #30 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 $


Offline AIR

  • BASIC Developer
  • Posts: 684
Re: SB Pi
« Reply #31 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.

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB Pi
« Reply #32 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.

Offline AIR

  • BASIC Developer
  • Posts: 684
Re: SB Pi
« Reply #33 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...

Offline AIR

  • BASIC Developer
  • Posts: 684
Re: SB Pi
« Reply #34 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.

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB Pi
« Reply #35 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.
« Last Edit: March 23, 2019, 09:37:28 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB Pi
« Reply #36 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 $
« Last Edit: March 23, 2019, 10:35:00 PM by John »

Offline AIR

  • BASIC Developer
  • Posts: 684
Re: SB Pi
« Reply #37 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.

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB Pi
« Reply #38 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 $
« Last Edit: March 23, 2019, 10:44:56 PM by John »

Offline AIR

  • BASIC Developer
  • Posts: 684
Re: SB Pi
« Reply #39 on: March 23, 2019, 10:44:44 PM »
The appimage is called "sb" not "scriba".

what's the output with the "-D" switch?

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB Pi
« Reply #40 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 $


« Last Edit: March 23, 2019, 10:56:36 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB Pi
« Reply #41 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.
« Last Edit: March 24, 2019, 09:50:42 AM by John »

Offline AIR

  • BASIC Developer
  • Posts: 684
Re: SB Pi
« Reply #42 on: March 24, 2019, 10:57:07 AM »

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB Pi
« Reply #43 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.


Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB Pi
« Reply #44 on: March 24, 2019, 11:28:49 AM »
AIR,

Can you post an example for your JSON and RE extension modules?