Log In  


Cart #picoterm-1 | 2026-09-26 | Embed ▽ | License: CC4-BY-NC-SA


This program lets users run a background python script that connects to Picotron via TCP socket. It is specially made for setups where you boot or auto-login into Picotron, just add the .py file to your startup, and you're good to go. NOTE: Currently interactive terminal applications are not supported, because the script

Setup

For Picotron, just unsandbox the cart and run it, it will install the latest version to /appdata/system/util Then just run picoterm in the terminal to connect. NOTE: The TCP socket is ONLY exposed to the machine itself, so be sure to run the script on the same machine as Picotron, if you would like to change this open the python script and change HOST = '127.0.0.1' to HOST = '0.0.0.0' Here is the python code (NOTE: This only works on MacOS and Linux, if you would like to make a windows version please feel free) NOTE: This program need the pexpect module, make sure you have that installed

#!/usr/bin/env python3
#Python Socket Template/Code Snippet by Real Python. https://realpython.com/python-sockets/
import socket
import pexpect
import time
child = pexpect.spawn('/bin/dash')
HOST = "127.0.0.1"  # Standard loopback interface address (localhost), CHANGE THIS TO '0.0.0.0' IF YOU WANT TO EXPOSE THE SCRIPT TO YOUR LOCAL NETWORK, BASICALLY LIKE SSH
PORT = 8090  # Port to listen on (non-privileged ports are > 1023)
while True:
 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # Make the socket reuse the port to prevent 'address in use' errors.
    s.bind((HOST, PORT)) # Binds the socket to the host port
    s.listen() # Wait for incoming socket data
    conn, addr = s.accept() # Accept the incoming connection
    cip, cport = addr # Assign the client ip and port to some varibles
    # This only allows connections from your machine, so people on your network can't control your computer
    with conn:
        # This block is just to get a shell prompt to appear on the other end
        print(f"Connected by {addr}") # Log output
        child.sendline('') # "Wake up" the shell
        child.expect(r'[\r\n][\$#>]\s+') # Wait for prompt
        shel = '$ ' # Read the output
        print(f"Sent {shel}") # Log output
        conn.sendall(shel.encode('utf-8')) # Send shell output
        # This is the main execution loop
        while True:
            try:
                data = conn.recv(1024) # Recieve the data
            except:
               break # Command fails, exit the loop
            child.sendline(data.decode('utf-8')) # Execute the data/command in the shell
            print(f"Revieced {data}") # Log output
            if not data: # If no data exit the loop
                break
            after = b'' # Initialize some varibles
            before = b''
            # This just gets the most recent prompt
            while True:
                index = child.expect([r'[\r\n][\$#>]\s+', pexpect.TIMEOUT], timeout=0.2) # Look for prompt, but if it takes longer than 0.2 seconds stop
                if index == 1: # If timeout reached
                    break # Exit Loop
                after = child.after + after # If timeout not reached add to the varibles
                before = child.before + before
            shel = before + after # Add the varibles together
            shel = shel.replace("$ ".encode('utf-8'), b'') + '$ '.encode('utf-8') # Make sure that there is only one prompt
            print(f"Sent {shel}") # Log Message
            conn.sendall(shel) # Send shell output

So, once you have saved the python file, just run the python file, then run picoterm. NOTE: If for any reason the script crashes then picoterm will hang.

I did use small amounts of AI to push up on my python and lua, please don't hate me for that



..you used AI and uploaded it to a site that doesn't allow it.. maybe just, don't?

(and the community, and just searching online, is available for you to learn stuff)


So I used AI for learning python, not making code (except for two lines of python) because i did this on a school computer, where many things are blocked
It was 2 lines of python code, what am i supposed to do, rewrite two lines?


Also, I felt like I should be honest. Like would you rather me lie and say that those two lines, weren't AI. And I think I wasn't violating the spirit of the law, to my understanding.


its still ai content sigh

Content that contains the output of AI models trained on the work of uncredited authors may not be posted on the BBS or podnet *.

it is very clear..

imo you should just, not use ai and learn the skills yourself, but you can also write non ai code or post it to another platform if you want to use ai...


Could you let it slide this one time, because this is my first Picotron cart, it was 2 lines of AI code, and I wasn't aware that the rules were this serious


I'm not zep...

I wouldn't see why you can't make a slop-free version of the code and just put that on there, since you said the picotron cart doesn't use AI - then it wouldn't be AI content on the BBS.


Ok, well, I would love to do that, but the problem is this is the ai code

            while True:
                index = child.expect([r'[\r\n][\$#>]\s+', pexpect.TIMEOUT], timeout=0.2) # Look for prompt, but if it takes longer than 0.2 seconds stop
                if index == 1: # If timeout reached
                    break # Exit Loop

This is the only code that was copy-pasted from AI, so how would I make it different if it's so simple?
P.S. I know that you're not zep, but I respect you as a member of the community and I don't want you mad/disproving of me.


1

I'd wager the rules are less about getting help writing the code (though even that is discouraged), than it is an attempt to prevent people to just have ChatGPT write code for them and just posting it.

If you wanted, you could try to understand the script and how it works, and then rewrite it yourself. That really shouldn't be that bothersome since it's small, and you'd learn in the process.

In the future, though, I would lean towards not using AI at all. The internet has plenty of human-provided information about stuff like this, and even if it doesn't, people on the BBS are definitely more than willing to help you out.


2

@ear_balm Thank you! That was like my exact philosophy. And I do plan to use no AI in the future.


1

bit iffy about this project in particular, but i also dont have a good solution for the situation

what @ear_balm said should work well though
happy to hear the no AI stuffs, we're always happy to help with stuff like this, either here, on the BBS or the new social platforms popping up on picotron

the wiki is also a wonderful resource


1

Glad this is all sorted out!



[Please log in to post a comment]