Shop OBEX P1 Docs P2 Docs Learn Events
Command Line Adventures — Parallax Forums

Command Line Adventures

doggiedocdoggiedoc Posts: 2,243
edited 2013-04-10 14:31 in General Discussion
In a concurrent thread I mentioned get a Linux system together. Mostly as an exercise I have chosen to forego a GUI. :tongue:

At this point I have successfully installed and tested a basic 'hello world.c' and using bstc I have compiled and run a simple toggle program written in spin.

My current brick wall is how to produce terminal output from spin. I can do it in c but I'm stumped on how to approach this from the command line of a bare bones Linux box.


Thanks for any insight.

Doc
«1

Comments

  • mindrobotsmindrobots Posts: 6,506
    edited 2013-04-06 08:04
    I assume you mean how to open up a terminal to talk to a Prop that is spitting out things via the PST object or Full Duplex Serial or whatever other Spin you are using to do I/O to pins 30/31?

    minicom is a widely used old standard program for talking to serial ports. It may be installed already, if not, you can find it in the Ubuntu Software library. Google "minicom tutorial" and you will be a guru in no time at all.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2013-04-06 08:05
    I was going to mention minicom too, but mindrobots beat me to it.

    Did you find the "man" command yet?

    Jeff
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-04-06 08:18
    I was going to mention minicom too, but mindrobots beat me to it.

    Just by moments!! :smile:

    Paul, as a WARNING, having a Linux system is a Pandora's box full of distraction and diversion for someone with our enhanced powers of attention deficit!! There is so much to play with and so many rabbit holes to chase down....it's an AWESOME playground!!!!
  • doggiedocdoggiedoc Posts: 2,243
    edited 2013-04-06 08:25
    Sorry Rick, can't read your reply.... to busy compiling minicom. :D:D
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-04-06 08:32
    doggiedoc wrote: »
    Sorry Rick, can't read your reply.... to busy compiling minicom. :D:D

    That's OK, I only took time to write it because I was downloading things to take off on the PropJS adventure that heater started me on! Gotta run.....there's something shiny off in the distance!
  • doggiedocdoggiedoc Posts: 2,243
    edited 2013-04-06 09:08
    OK, got mini com mostly working. It took me a little while to figure out I forget to call pst.start() :D

    But... I can't seem to get minicom to exit ... having to resort to killing power
    :(
  • frank freedmanfrank freedman Posts: 1,983
    edited 2013-04-06 09:37
    Hey DDoc,

    Remember you can open multiple log ons using the alt-Fn key sequence. If you had say done an alt-f2, started minicom and then same but different Fnn key, you could do write compile run in one cmd screen, then alt-Fnn to the screen with minicom to watch/interact with the result. I have not tried this yet, but you should be able to set fdx object to different pins to use so as to have multiple serial channels running.

    That said, I have on occasion had a program lock up the current window without the ability to do an alt-Fnn. The way to get out of this bind is to have ssh enabled (BUT NOT AS ROOT). That way you can ssh into the box as you or a maint account. Then do
    Ps - ef. to find your process id. May need to use more/less if too much scrolls by then
    Kill -9 nnnnnn where process id is the id of the program or terminal session you want ended.

    Don't make a habit of doing this as root. If you get the PID wrong you can take down the box and loose any unsaved work. Just remember that as root the machine will think you are god. It will obey with little or no hesitation. It will rarely ask are you sure. Just think what this could do:

    /# rm -rf * (the / is current directory and # is the prompt). The man page and google are your friends.

    Yep, all gone..... This will give you the rare are you sure question, unless it was aliased out..... Then simply enter and all goes by- by...
  • Heater.Heater. Posts: 21,230
    edited 2013-04-06 09:40
    Isn't it something odd like Control-a and the z.
    Normally it tells you.
  • doggiedocdoggiedoc Posts: 2,243
    edited 2013-04-06 09:53
    Yes, but when I pressed that key combo... nothing happened. I turns out I have to press them repeatedly I assume to catch it at vulnerable moment. :D:D
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-04-06 12:06
    Does adding your user to dialout group allow us to use minicom on ttyUSB0 without have to use sudo?

    I want to try this, but I don't want to screw up my system.

    EDIT - HEY! I think I already did this when setting up simpleIDE, and it works! Go figure. I should pay more attention.
  • Heater.Heater. Posts: 21,230
    edited 2013-04-06 12:08
    That should work, Braino. Not much damage to do there.
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-04-06 12:11
    Thanks for confirming. This was bugging me for two weeks. This is awesome
  • doggiedocdoggiedoc Posts: 2,243
    edited 2013-04-06 12:17
    Does adding your user to dialout group allow us to use minicom on ttyUSB0 without have to use sudo?

    I want to try this, but I don't want to screw up my system.

    EDIT - HEY! I think I already did this when setting up simpleIDE, and it works! Go figure. I should pay more attention.
    That's what I did. It's working fine now. Albeit slow to respond to cntrl-a +z +x ......

    While I was dinking around I also compiled Roy's Open-source-spin-compiler. It compiles spin files without problem. Didn't find any provision for loading... but didn't look to hard.


    Lastly I thought the day wouldn't be complete unless I made it do minecraft. So I compiled java and set up a minecraft server. :D I might start liking Linux if I'm not careful. :D:D
  • Heater.Heater. Posts: 21,230
    edited 2013-04-06 12:23
    I think you will want to use the loader that comes with propgcc with Roy's compiler ( Don't forget we call it "SpinRoy" around here:))
    Or I guess BSTL.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-04-06 13:34
    mindrobots wrote:
    [re: command-line Linux] ... it's an AWESOME playground!!!!
    Or a soul-sucking morass, depending upon your point of view! :)

    -Phil
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-04-06 14:28
    Or a soul-sucking morass, depending upon your point of view! :)

    -Phil

    Yes, I use Perl on Linux, too!!! :0) (another amazing tool that will drive you to madness!!!)
  • frank freedmanfrank freedman Posts: 1,983
    edited 2013-04-06 14:54
    Madness only if you fail to fully realize the power of the mystical regex........
    mindrobots wrote: »
    Yes, I use Perl on Linux, too!!! :0) (another amazing tool that will drive you to madness!!!)
  • doggiedocdoggiedoc Posts: 2,243
    edited 2013-04-06 19:52
    Several years ago I read several books on PERL. It sure seemed like a good language to learn. I'm not sure what happened. Guess I got distracted......



    yeah.
  • SRLMSRLM Posts: 5,045
    edited 2013-04-07 00:06
    I prefer picocom over minicom. Picocom is simpler, has never locked up on me, and is quick to get started. Unfortunately, neither program has the option to, well, do something or another. I can't remember right now, but I think it has something to do with DTR.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-04-07 00:32
    doggiedoc wrote: »
    OK, got mini com mostly working. It took me a little while to figure out I forget to call pst.start() :D

    But... I can't seem to get minicom to exit ... having to resort to killing power
    :(

    If you can identify minicom's process number, you can use that number to kill the process rather than power down.

    When all else fails, just type 'MAN minicom' and read the documentation.
  • Heater.Heater. Posts: 21,230
    edited 2013-04-07 00:59
    doggiedoc.

    Perhaps you are having problems with minicom thinking its talking to a modem and wanting to hangup or reset it on exit. I seem to remember having some issue like that years ago. Except mine was the opposite, minicom would appear to not start.

    Try

    $sudo minicom -s

    Select "modem and dialing" from the menu.

    Make sure the Init and Reset strings are empty. You can probably empy everything there without harm I guess you don't use a modem

    On the way out select "Save setup as dfl" to make the changes stick.

    Exit minicom and try again as your normal user.
  • TorTor Posts: 2,010
    edited 2013-04-07 02:29
    doggiedoc wrote: »
    Several years ago I read several books on PERL. It sure seemed like a good language to learn. I'm not sure what happened. Guess I got distracted......
    You just need the 'Perl Cookbook' (O'Reilly). That one makes it incredibly easy to whip out a Perl script that actually does what you want. Just look up the right recipe and then go from there.

    -Tor
  • doggiedocdoggiedoc Posts: 2,243
    edited 2013-04-07 04:31
    @Loopy - I wasn't sure how to do that so I used 'man man' to get started :tongue:

    @Heater - thanks for the pointers... as it turns out, I wasn't pressing the keys properly. Minicom wants command key sequences not combinations as I was doing. :cool:

    @Tor - Yes, I have that book and I like it too. My interests seem to follow different paths these days.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-04-07 04:47
    Use 'ps" to get a listing of all active processes with their currently active PID number

    Use 'kill' to kill a process, but take a look at 'man kill' for how to do so.

    The command line in Linux is extremely powerful when compare to Windows. And mostly so because the 'man -k (keyword)' will take you to available documentation for most of what is installed and available.

    Of course, since you have to first start 'minicom' to get a PID, you have to open a second terminal window to do these things.
  • doggiedocdoggiedoc Posts: 2,243
    edited 2013-04-07 04:53
    I used a SCO Unix server for several years to run my practice before switching to Mac OSX, so it's not all completely new to me. :D
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-04-07 05:02
    I skipped Perl and have the Python manual and Python Cookbook that are just sitting here.

    @doggiedoc
    I use command line in Linux a lot, but haven't the courage to run a headless server.
  • doggiedocdoggiedoc Posts: 2,243
    edited 2013-04-07 06:15
    Both of my Mac OSX servers at work are headless and I'll likely repurpose the monitor from the new Linux box since it doesn't have a GUI installed anyway. The only thing is the java process for Minecraft. I can stop it remotely but haven't figured out how to start it remotely without leaving the remote terminal session up. I do have a Mac Pro at home that serves our media to the LAN so I can move the process to a session on that machine. Problems solved.
  • Heater.Heater. Posts: 21,230
    edited 2013-04-07 06:20
    doggoidoc,

    Check out the nohup command. http://en.wikipedia.org/wiki/Nohup
    Allows you to logout and leave things running. Not the best solution but has worked very well for us.
  • doggiedocdoggiedoc Posts: 2,243
    edited 2013-04-07 06:29
    Thanks Heater - that looks like a good solution.



    EDIT: Quick test = seems to work fine.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-04-07 09:12
    Actually, I do have a headless Linux in operation.. my Asus router has been reloaded with Linux 2.6 firmware from Oleg-the-Russian. And that certainly is headless, with wifi no less. It works very nicely as a printer server. I could have it be a Linux and Windows file server with Samba and do several other fancy things, but I am a bit lazy. It will take a USB hard drive of large proportions and the nicest thing about it is that the 24/7 power bill is far less than any other box I could set up.

    It is definetly NOT Ubuntu Linux.. probably Debian of sorts. No Xwindows, very small amount of storage and SRAM.
Sign In or Register to comment.