Go to advanced search

by liudr
Wed Oct 10, 2018 2:05 pm
Forum: General discussion
Topic: Load same history every time
Replies: 10
Views: 736

Re: Load same history every time

tpyo kingg wrote:
Mon Oct 08, 2018 2:54 pm
That would go in the user's .bashrc file.
Thanks.
by liudr
Mon Oct 08, 2018 2:29 pm
Forum: General discussion
Topic: Any PC software that can make backup images of RPI?
Replies: 1
Views: 288

Any PC software that can make backup images of RPI?

I've been using "Paragon backup and recovery 2014" to back up my RPIs until the more recent distro that breaks it (restored images wouldn't boot). I can use the win32 disk imager if I have to, dumping sectors instead of recording drive content and skipping over empty spaces and any memory swap files...
by liudr
Mon Oct 08, 2018 2:24 pm
Forum: General discussion
Topic: Load same history every time
Replies: 10
Views: 736

Re: Load same history every time

Rather than overwrite .bash_history another way would be to unset the $HISTFILE variable: unset HISTFILE; history -r /home/pi/Documents/cmd_history.txt It's fewer steps but that may not matter so much. Thanks. I'll try this as well. Will this have to be done just once per user account or included i...
by liudr
Mon Oct 08, 2018 2:20 pm
Forum: General discussion
Topic: Load same history every time
Replies: 10
Views: 736

Re: Load same history every time

Include the command to run your “clean-up history” script in your predefined command history. Then the user can run that command anytime when he/she feels there is a need. If you need to have the command history always only remember the predefined commands, nothing else. Then you may create a scrip...
by liudr
Fri Oct 05, 2018 5:20 am
Forum: General discussion
Topic: Load same history every time
Replies: 10
Views: 736

Re: Load same history every time

Background: The RPI is sealed in a waterproof box with a display and a few push buttons around the box's sides. It's to be used in the field where people may wear gloves and have water and dust and probably grease. They need to select what command to run and not have to run them in any particular se...
by liudr
Fri Oct 05, 2018 3:44 am
Forum: General discussion
Topic: Load same history every time
Replies: 10
Views: 736

Load same history every time

I'm trying to have a pre-defined list of commands in history each time I start terminal so I can quickly do a few tasks with the up arrow and enter buttons only. I tried this in .bashrc but that didn't work at first: history -c;history -r /home/pi/Documents/cmd_history.txt Whatever I did before clos...
by liudr
Fri Sep 21, 2018 1:30 am
Forum: General discussion
Topic: Shut down rpi with a keyboard key combo
Replies: 12
Views: 1238

Re: Shut down rpi with a keyboard key combo

Is this any use: https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=206921#p1280779 It won't physically remove power, but nothing internal to the Pi will do that without extra/external hardware. However it does put the Pi into a state whereby you can just safely "pull the plug". BTW: Note that...
by liudr
Wed Sep 19, 2018 9:31 pm
Forum: General discussion
Topic: Shut down rpi with a keyboard key combo
Replies: 12
Views: 1238

Re: Shut down rpi with a keyboard key combo

What if your GUI is focused on a file browser? Will that key sequence delete an important file without confirmation? What if you're focused on a terminal windows that is running a Python code? :lol: I'm looking for a method that will initiate a shutdown process regardless which window gets the focus...
by liudr
Wed Sep 19, 2018 7:29 pm
Forum: General discussion
Topic: Shut down rpi with a keyboard key combo
Replies: 12
Views: 1238

Shut down rpi with a keyboard key combo

I've seen plenty of projects describing how to shut down rpi with a push button connected to a GPIO pin and running a python script to catch the button push. I thought why not setting up a keyboard combo for shutdown or other stuff? If I can do that under GUI, I can replace the real keyboard with an...
by liudr
Thu Sep 06, 2018 4:14 am
Forum: Python
Topic: Trying to make python import work
Replies: 9
Views: 708

Re: Trying to make python import work

Yes, I like the duck type where you can just pass an object to a function to be used. It's more flexible than C++. Anyway, that doesn't help me with the separate namespace issues. I want variables and functions stored in other files to be incorporated into the main name space like they were defined ...
by liudr
Wed Sep 05, 2018 2:33 pm
Forum: Python
Topic: Trying to make python import work
Replies: 9
Views: 708

Re: Trying to make python import work

Thanks OutoftheBOTS. For now I'll keep all my functions in one file and look for elegant solutions/reduce or eliminate global variables at the same time. The source of my problem is with MicroPython and wanting to keep project code on sd card while wanting the project code to have access to all the ...
by liudr
Wed Sep 05, 2018 2:29 pm
Forum: Python
Topic: Cross Compilation Tool for Python
Replies: 7
Views: 1179

Re: Cross Compilation Tool for Python

OK, so you want experience programming Arduino to translate into programming raspberry pi? The PC doesn't have rpi's hardware. Like Heater said, do some fake modules to accommodate the code. Rather, I suggest you to NOT use ANY RPI hardware if possible. Instead, connect an arduino to raspberry pi an...
by liudr
Wed Sep 05, 2018 4:37 am
Forum: Python
Topic: Cross Compilation Tool for Python
Replies: 7
Views: 1179

Re: Cross Compilation Tool for Python

As far as I know, Python code requires an interpreter to run. It doesn't compile into machine-specific code like C/C++. Cross compilation is only relevant to languages that compile into machine-specific code. You set up a compiler that turns source into machine-specific code that runs on an OS or CP...
by liudr
Wed Sep 05, 2018 4:22 am
Forum: Python
Topic: Trying to make python import work
Replies: 9
Views: 708

Re: Trying to make python import work

From a general programming point of view, splitting a single long program into several shorter programs is a common task, not a C++ only feature. I will explore this further. I'm not convinced that python lacks this basic feature.
by liudr
Tue Sep 04, 2018 9:58 pm
Forum: Python
Topic: Trying to make python import work
Replies: 9
Views: 708

Re: Trying to make python import work

That's what I am dreading, passing everything from caller to function as parameters. It breaks the symmetry between having these functions defined in the same file and having them defined (unaltered) in separate files. In the same file, globals penetrate through function defs. Once you move the func...
by liudr
Tue Sep 04, 2018 9:42 pm
Forum: Python
Topic: Trying to make python import work
Replies: 9
Views: 708

Trying to make python import work

I have some simple tasks to do but am stuck on the import mechanism. I know that python import is not to be compared with C include or global declarations but I'm looking for simple ways to have a shared name space. Here is what I have in two files: main.py import math a='haha' from doit import * do...
by liudr
Sun Aug 26, 2018 5:45 am
Forum: Python
Topic: Publish data so other processes may use them
Replies: 3
Views: 423

Re: Publish data so other processes may use them

Thanks. I was just reading another thread in the subforum. It's about the same question:

https://www.raspberrypi.org/forums/view ... 2&t=221049

I am reading up MQTT. Seems to be exactly what I was hoping for: publisher, subscriber, broker. Learned something new!
by liudr
Sun Aug 26, 2018 5:24 am
Forum: Python
Topic: Publish data so other processes may use them
Replies: 3
Views: 423

Publish data so other processes may use them

Hi, I am trying to make one python script publish some results it collects so that other processes, python or not, can make use of the results. Imagine the python script is a weather station and it publishes temperature and soil moisture. The data may be helpful for a process that controls in-ground...
by liudr
Thu Jul 05, 2018 4:19 pm
Forum: Python
Topic: Regular expression that turns into a python syntax question
Replies: 11
Views: 764

Re: Regular expression that turns into a python syntax question

Thanks for taking the time to explain. Maybe one will be a more future-proof way than the other? If I can bet that .match() will always be returning None in future versions, it seems to be a more accurate way to do the if-statement. I'm frankly not sure what None represents, coming from a C/C++ back...
by liudr
Tue Jul 03, 2018 8:40 pm
Forum: Python
Topic: Regular expression that turns into a python syntax question
Replies: 11
Views: 764

Re: Regular expression that turns into a python syntax question

The re.search function returns a match object on success, none on failure. https://www.tutorialspoint.com/python/python_reg_expressions.htm Instead of testing for true test for if (m is not None): Fixed your link. Thanks. The answer ericcooper provided was what I was looking for, reason that m is c...
by liudr
Tue Jul 03, 2018 8:34 pm
Forum: Python
Topic: Regular expression that turns into a python syntax question
Replies: 11
Views: 764

Re: Regular expression that turns into a python syntax question

ericcooper wrote:
Tue Jul 03, 2018 8:28 pm
Any non-zero / non-empty value is treated as True for "if" statements and other conditionals.
I see. That's why. It makes sense. Thanks.
by liudr
Tue Jul 03, 2018 8:13 pm
Forum: Python
Topic: Regular expression that turns into a python syntax question
Replies: 11
Views: 764

Regular expression that turns into a python syntax question

I am using regular expression to match a number at the end of a string using '[0-9]$'. It works perfectly except when the string is empty (didn't get a response from serial port). See the following snippet: m=re.search('[0-9]$','A7') print(m.group(0)) I read from Python doc that the m object evaluat...
by liudr
Fri Jun 29, 2018 8:22 pm
Forum: Python
Topic: What communication protocol does Pyserial run?
Replies: 8
Views: 812

Re: What communication protocol does Pyserial run?

Your servo needs 5V UART. I think you mentioned that you have a 3.3V to 5V converter so it's covered. The problem may be the code, which is long. I suggest you to use the adapter the manufacturer sells and tap into the adapter and listen to the communication. There are serial port sniffer software t...
by liudr
Fri Jun 29, 2018 7:09 pm
Forum: Python
Topic: What communication protocol does Pyserial run?
Replies: 8
Views: 812

Re: What communication protocol does Pyserial run?

Does the write function in PySerial automatically add the start and stop bits onto the data I am trying to transmit? This is the byte array that I am transmitting through the connection: b'\x15\xaa\x87\xe8\xae' No, pyserial calls lower-level functions probably in the system and hands over the data....
by liudr
Fri Jun 29, 2018 5:03 pm
Forum: Python
Topic: Issue with Pyserial module extracting device serial number
Replies: 9
Views: 1457

Re: Issue with Pyserial module extracting device serial number

Thanks. Here is my new code to detect the correct USB-UART adapter on windows system (I'll test it on linux tonight but don't expect it will fail): import serial.tools.list_ports # For listing available serial ports import serial # For serial communication port_ID='A817EQLG' # List ports for user to...

Go to advanced search