English Amiga Board


Go Back   English Amiga Board > Support > support.FS-UAE

 
 
Thread Tools
Old 27 January 2015, 14:59   #1
lallafa
Registered User
 
Join Date: Aug 2010
Location: Erlangen, Germany
Posts: 23
A lua shell for FS-UAE

I really like the scripting interface for FS-UAE with lua, but playing with it was quite hard as you have to edit scripts and relaunch the emulator every time to see what happens (or not)...

What I was missing is a shell where you can interactively enter commands...

On my fs-uae-gles/lua branch on github I have added such a shell...

Simply compile FS-UAE with --enable-lua and enable the shell with "lua_shell = 1" in your config. Then you can connect via telnet to localhost:6800 and have fun:

Code:
telnet localhost 6800
FS-UAE 2.5.27dev Lua 5.2
>
The shell works very similar to the lua interpreter "lua", e.g. a line beginning with = returns the value of the expression.
Use "quit" to exit the shell.

Frode, if you like this feature, I can prepare you a pull request or a patch for inclusion in the main tree... The code was developed on OS X and tested on Linux. Windows may need some minor fixes, I guess.

Under the hood I have cleaned up the whole scripting layer: merged states in fs and uae layer and refactored the commands into "fsemu", "fsuae", "uae" lua libraries...

The nice bonus feature of the shell is that we now have a mechanism to change floppy and cd images while the emulator is running... E.g. the launcher can attach the emulator after start up and then change images by sending lua commands...

Code:
fsuae.floppy_set_file(0,"/path/to/my.adf")
should do the trick...

Currently, I am playing around with the commands to see what actually works (the shell changes the emulator state while its running...) and what to avoid doing

Last edited by lallafa; 05 February 2015 at 11:47. Reason: corrections applied as reported by jbl007
lallafa is offline  
Old 28 January 2015, 20:23   #2
jbl007
Registered User
 
Join Date: Mar 2013
Location: Leipzig/Germany
Posts: 416
I like the idea.
But I get connection refused from telnet. As far as I can see it does not listen on port 6800. (netstat -npl)

Code:
$ amiga --log | grep -i lua
lua_shell = true
lua-fs: init
lua-fs: registered function 'log'
fs_emu_theme_init_lua
fs_emu_render_init_lua
lua-fs: registered function 'set_scale'
lua-fs: registered function 'set_frame_position_and_size'
lua-fs: registered function 'load_shader'
lua-fs: registered function 'set_shader'
lua-fs: not bound: postpone handler 'on_fs_emu_init_video'
lua-fs: not bound: postpone handler 'on_fs_emu_render_frame'
lua: init
lua-fs: bound to emu
lua-fs: calling postponed handler 'on_fs_emu_init_video'
lua-fs: calling postponed handler 'on_fs_emu_render_frame'
lua-shell: disabled
lua: free
lua-shell: stopping...
lua-fs: unbound from emu
lua-fs: not bound: postpone handler 'on_fs_emu_render_frame'
jbl007 is offline  
Old 29 January 2015, 16:42   #3
lallafa
Registered User
 
Join Date: Aug 2010
Location: Erlangen, Germany
Posts: 23
Ah.. my fault: The correct way to set the option is:
Code:
lua_shell = 1
lallafa is offline  
Old 29 January 2015, 20:32   #4
jbl007
Registered User
 
Join Date: Mar 2013
Location: Leipzig/Germany
Posts: 416
Ok, it works!
Before someone else runs into trouble: It's not fsuae.set_floppy_file(), it's fsuae.floppy_set_file()

Which commands do work? Is it possible for example to change the volume or toggle the LED (filter).
jbl007 is offline  
Old 16 March 2015, 19:26   #5
lallafa
Registered User
 
Join Date: Aug 2010
Location: Erlangen, Germany
Posts: 23
Some updates here:

I moved the source of the lua shell to a new repo:

https://github.com/cnvogelg/fs-uae/tree/lua

This repo is a direct fork of Frode's repo and will simplify a later pull request.

The branch now compiles and works on OS X, Linux, and Windows.

Currently, my main focus is on making drive image handling work from external tools.
I have written a small python library to access the lua shell from own tools.
Also a small command line utility in tools/fs-uae-ctl was added:

Code:
fs-uae-ctl df0 image.adf   # insert a disk image into df0
fs-uae-ctl df1 eject    # eject disk in df1
fs-uae-ctl df2   # show current image in df2

fs-uae-ctl cd0 my.iso   # insert CDROM image
fs-uae-ctl cd1 eject
fs-uae-ctl cd2
Next will be a small PyQT UI for handling the drive images...
lallafa is offline  
Old 19 March 2015, 21:37   #6
lallafa
Registered User
 
Join Date: Aug 2010
Location: Erlangen, Germany
Posts: 23
Here we go: fs-uae-ctl-ui (also located in tools)

This little UI lets you change floppy disk and CDROM images with a few mouse clicks while running FS-UAE...

Have Fun!
Attached Thumbnails
Click image for larger version

Name:	fs-uae-ctl-ui.jpg
Views:	272
Size:	89.4 KB
ID:	43647  
lallafa is offline  
Old 22 March 2015, 00:22   #7
jbl007
Registered User
 
Join Date: Mar 2013
Location: Leipzig/Germany
Posts: 416
Nice, thanks for this!
I didn't like a separate window for changing floppy disks, so i made something else based on you lib: https://github.com/sonnenscheinchen/...ster/fs-uae.py It is some kind of wrapper for the (linux-) fs-uae executable with the ability to change floppies from the systray.

The main problem is still: If you quit the emulator without closing the connection there is (obviously) no way to disconnect and you get "connection refused" if you restart in a short period of time.
jbl007 is offline  
Old 22 March 2015, 19:04   #8
lallafa
Registered User
 
Join Date: Aug 2010
Location: Erlangen, Germany
Posts: 23
Nice work, too! I like the idea with the systray

Quote:
Originally Posted by jbl007 View Post
The main problem is still: If you quit the emulator without closing the connection there is (obviously) no way to disconnect and you get "connection refused" if you restart in a short period of time.
I just added the socket option SO_REUSEADDR. That should allow binding the socket even if the emulator restarts quickly.
lallafa is offline  
Old 22 March 2015, 20:19   #9
jbl007
Registered User
 
Join Date: Mar 2013
Location: Leipzig/Germany
Posts: 416
Quote:
Originally Posted by lallafa View Post
Nice work, too! I like the idea with the systray
New version features dynamic menus: You can change floppies in fs-uae (F12) as well and the menus will notice.

Quote:
I just added the socket option SO_REUSEADDR. That should allow binding the socket even if the emulator restarts quickly.
Yes this helps, thanks.
jbl007 is offline  
Old 13 August 2020, 20:57   #10
simonhez
Registered User

simonhez's Avatar
 
Join Date: Aug 2020
Location: Ottawa
Posts: 41
is there a way to build the tool for disk swapping in the current version of FS-UAE?
simonhez is offline  
Old 14 August 2020, 20:35   #11
jbl007
Registered User
 
Join Date: Mar 2013
Location: Leipzig/Germany
Posts: 416
Quote:
Originally Posted by simonhez View Post
is there a way to build the tool for disk swapping in the current version of FS-UAE?
I tried and it looks like it still works.

Code:
telnet localhost 6800
Trying ::1...
Connection failed: Verbindungsaufbau abgelehnt
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
FS-UAE 3.0.4 Lua 5.2
> =1+1
2
> ="it works"
it works
>
https://github.com/sonnenscheinchen/fs-uae/commits/lua
Attached Thumbnails
Click image for larger version

Name:	ctl-ui.png
Views:	34
Size:	39.3 KB
ID:	68487  
jbl007 is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lua interpreter with arbitrary precision math. Thorham Coders. Releases 19 06 January 2020 23:13
Shell help? madman support.Apps 5 24 June 2011 22:32
Clear background color for Shell window- Shell-StartUp fc.studio support.Apps 12 29 December 2009 14:21
AmigaDOS web shell copse Coders. General 1 21 December 2009 02:04
Shell Replacement amiga request.UAE Wishlist 6 22 January 2009 19:44

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 17:17.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.13084 seconds with 16 queries