Author Topic: SB π  (Read 7444 times)

Offline John

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

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB Pi
« Reply #16 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.
« Last Edit: March 22, 2019, 04:23:30 AM by John »

Offline AIR

  • BASIC Developer
  • Posts: 684
Re: SB Pi
« Reply #17 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.
« Last Edit: March 22, 2019, 01:47:27 PM by AIR »

Offline John

  • Forum Support / SB Dev
  • Posts: 2745
    • ScriptBasic Open Source Project
Re: SB Pi
« Reply #18 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)
« Last Edit: March 22, 2019, 02:28:31 PM by John »

Offline John

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

« Last Edit: March 22, 2019, 05:37:46 PM by John »

Offline John

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



Offline John

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

Offline John

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

Offline John

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

Offline AIR

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

Offline John

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

Offline AIR

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

Offline John

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

Offline John

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

Offline AIR

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