home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.sys.cbm      Discussion about Commodore micros      53,866 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 51,918 of 53,866   
   Dropnine to All   
   Re: Using tcpser on a Pi for telnet gate   
   07 Apr 17 08:20:22   
   
   From: dropnine@gmail.com   
      
   Step 2 - Making TCPSer a service that boots with the Pi    
   ---   
   (Edit 5APR2017:   
     - corrected the .service file contents   
     - added file permissions to allow tcpser to execute and stay resident at boot   
   )   
      
   So I had a number of pm's stating that their Pi's were not working with the   
   instructions. the service would start manually, but not autostart.  This   
   worked fine with my old version of noobs, however I did notice that the latest   
   raspian lite img was,    
   indeed breaking with the previous instructions.  The target I set out from in   
   the beginning is to have tcpser run as a *service*.  This gives the OS much   
   more flexibility and is not a hack.   
      
   I was asked to explain, why make it into a service.  There are a number of   
   reasons, but in short, a service is meant to continue on in the event of an   
   error and not stop.  The error is directed to a log and you can inspect the   
   status at a level which is    
   approachable.  We can check the status of the service with a -l command and it   
   will give us direct info of the error that accurred and we can investigate and   
   correct the error, etc. quickly--which is always the case in my job.  It's   
   just a good habit and    
   best practice to get into so that it is much less frustrating.     
      
   ** You can hack the rc.local file and enter the tcpser command into that to   
   make it autoboot -- make sure you include the & at the end of the command or   
   you'll never get to a login prompt.  That is just one issue that may occur   
   when the system hangs at    
   boot.  That file is read-only for a reason...but you can use it.  There will   
   also be no indication as why the application does not work when it fails and   
   that is a total misery to work through.   
      
   ** Alternatively, you can also move the serialBridge file into the   
   /etc/init.d/ directory and than issue some commands to enable it; this is more   
   of a brute force sort of approach and requires some programming to do it   
   properly.   
      
      
   So here's the final version and I know this to work as I recreated it last   
   night.  I obtained the raspbian lite image and wrote the image to a 4GB SD   
   card.  I then booted the Pi, setup my max232 and the GPIO as in step 1. I then   
   installed tcpser as in    
   the mandetory step from the previous instructions.  I then went on to document   
   the steps below.  I then did the whole process again, this time working from   
   the document below to confirm it was proper.   
      
   ----   
   Here is the edited STEP 2 instructions to create tcpser as a service on LINUX   
   (make sure the other steps are followed before going forward with this):   
      
   Two text files need to be created.  One is the executable file that has the   
   instructions to start tcpser with our default values and another text file   
   that instructs LINUX how to start the first file as a bootable service.    
      
   1. Create a text file (I just put it in the Pi home directory) and make it   
   executable.  If you are using a USB to Serial Adaptor, change the ttyAMA0 to   
   ttyUSB0 in the following instructions (or the ttyUSB# that represents where   
   your adaptor is active    
   using the command: lsusb -t at the bash).  Change the 38400 baud rate value in   
   the tcpser line to whatever suites your setup. The max232 that I have can go   
   from 300 baud to 115200 baud.  There are some that cannot go any lower than   
   57600, so please make    
   sure you know your type.  USB to serial devices are known to be very bad and   
   buggy.  Use them at your own risk.  My advice is to purchase a USB-Serial   
   device that is more than 10 bucks CDN.   
      
   To create the proper text file, at the bash:    
      
   type: cd     
   type: vi serialBridge     
   type: i    
   type: #!/bin/sh     
   type: tcpser -s 38400 -d /dev/ttyAMA0 &    
   type :wq     
      
   You're now out of the editor and back at the bash. If you do an ls command,   
   you should see the new file, serialBridge, in the directory.  We now need to   
   make the file executable.  At the bash:    
      
   type: chmod +x serialBridge    
      
   2. Now that we have an executable file to start up tcpser with our default   
   values, we need to create another text file that instructs LINUX how to start   
   that file as a service when the OS boots. To do that, we create another text   
   file in a very specific    
   spot and then issue some commands to tell LINUX to use it when it's booting.   
   To do that, at the bash:    
      
   type: sudo vi /lib/systemd/system/serialBridge.service     
   type: i    
      
   Copy and paste everything between the # mark lines into the editor (or type it   
   in if you are a better typer than myself):    
      
   ####################    
   [Unit]    
   Description=Serial to TCP-IP Bridge    
   After=Multi-User.target    
      
   [Install]    
   WantedBy=Multi-user.target    
      
   [Service]    
   ExecStart=/home/pi/serialBridge    
   Type=forking   
   Restart=on-abort   
   #####################    
      
   You're still in the editor at this point, so to save and exit the editor type   
   the following:  :wq     
      
   You will now be out of the editor and at the bash prompt. To register the   
   executable as a service and start up the service immediately (no need to   
   reboot), at the bash:    
      
   type: sudo chmod 644 /lib/systemd/system/serialBridge.service       
      
   type: sudo systemctl daemon-reload   
   type: sudo systemctl enable serialBridge.service        
   type: sudo systemctl start serialBridge.service         
   type: sudo systemctl status serialBridge.service        
      
   The first command will reload the daemon server to acknowledge the new   
   changes.  The second command will instruct LINUX the service should be enabled   
   at boot (level 3).  The third command will tell LINUX to start the service   
   right now (so we can use it    
   right away without having to reboot everything).  The forth command will   
   display the status of the service we just started with the previous command so   
   we can see if it's actually enabled and ready to use.  If there is a   
   "disabled" status, then you need    
   to go back and check your typing or if the proper device is being used, etc.    
   If you are using a USB to Serial, the USB0 might have to be changed to   
   ttyUSB1, etc (check to see which one is active).   
      
   If your service is not active, then at the bash:   
      
   type: sudo systemctl status serialBridge.service -l       
      
   and look to see what the issue is.  More than likely it'll be a spelling   
   mistake or something simple.   
      
   Contact me like before if there are wierd issues with your Pi and these   
   instructions.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca