I recently needed to download a large number of files from a Linux server using SCP, which would take nearly 12 hours. When i checked the next day this transfer had stopped to ask if I wanted to overwrite a file. This was because two files had the same name, differing only in case.
I remembered there was a registry setting that could set the NTFS filesystem to be case sensitive[0], but I’d rather not do that on this workstation. I did a Google search anyway, but then I found there is a newer way to do this which is on a per-folder basis instead of globally[1].
There is a command called “fsutil.exe” that can adjust a lot of filesystem settings, one of them is “SetCaseSensitiveInfo”, which controls if the folder is case sensitive or not.
When I restarted the download, it still didn’t work, because that command only applies it to the specified folder, and any new folders created after. It does not apply to existing sub-folders. The following PowerShell command will apply the setting to any existing folder.
While working on a project that used the Microchip C18 compiler I got this error message:-
If I clicked āContinueā it would appear again instantly, and this kept going dozens of times, the compile worked fine but the error message was very annoying. The drive in question was a partition on my main hard disk, it was not a removable drive!
After a bit of research I found out how to suppress the error message by modifying the system registry. Below is an example of the .reg file I created.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows]
"ErrorMode"=dword:00000002
This will disable all application and system error pop-ups, which may not be what you want so what I did is create two reg files, on disables the errors, the other enables the errors. This means I can temporarily disable the errors when I want.
I tried to change the permissions of my ssh private/public keys in the .ssh directory under Cygwin on Windows 8 and it didnāt work. This seems to be a bug in Cygwin but there is a work around that I found throughĀ SuperUser.
chgrp -R Users ~/.ssh
Now all you need to do is run the chmod commands as usual and all should work.
I was debugging a project that used SIGUSR1 heavily, GDB stops on SIGUSR1 by default and it was making debugging a pain when I didnāt care when the signal was being generated. So here is now to set how GDB interprets signals.
By entering the following into the GDB prompt you can instruct it to not print, or stop when the signal happens and to pass it to the program.
Iāve been asked to help someone create a device that can play steam train whistle sounds when a button is pressed. I was given a load of MP4 video files with recordings of the whistles.
FirstĀ I wanted to rename them because they all had a āPrj ā prefix on them. The code snippet below is what I used to remove the prefix from the file names.
for file in *.mp4 ;
do
mv "$file" $(echo "$file" | sed 's/Prj //')
done
The next thing to do is extract the audio from all the videos. FFMPEG is perfect for this. The Bash code below will extract the audio fromĀ all of the MP4 files in a directory.
for file in *.mp4 ;
do
ffmpeg -i $file -map 0:1 -acodec pcm_s16le -ac 2 ${file/.mp4/.wav}
done
Now that Iāve got the audio files I need to open them in Audacity and edit them, that is something I canāt automate unfortunatelyĀ š¢
Recently I wondered how you control CPUĀ throttlingĀ in GNU/Linux systems so after doing a little research this script is what Iāve come up with. Itās based on some others that Iāve comeĀ across. All it does is set the CPU throttling mode to āperformanceā then displays the current CPU frequency setting, which should be full speed.
#!/bin/sh
for CPUGOV in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
do
echo -n performance > $CPUGOV;
done
# Display Stats about new settings
grep -E '^model name' /proc/cpuinfo | head -n 1
for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
do
cat $CPUFREQ | awk '{ print $1 / 1e6 "GHz"; }'
done
exit 0
There are a lot of different methods used to debounce switch inputs and this post is just about one method that I read about recently and used a couple of times now. So far it seems pretty good and does the job.
The C code for this method is just below, I defined it as a macro so I can use it for multiple switch inputs. All you need to do is execute this code at a fixed sample rate and it will do the rest.
What this basically does is average samples. When the input is high the āintegratorā counts up until it reaches the PERIOD constant. Then it sets the output high and also saturates the integrator to the value of PERIOD. When the input is low the integrator counts down until it reaches 0 when it sets the output low.
I cant remember where I found this method, I believe the link is somewhere on Jack Ganssleās website. He also has a good tutorial on switch debouncing.
When developing embedded firmware I like to define macros that provide aliases for the IO port registers that I need. The name of each of the macros will correspond to the net name on the schematic to make it easy to check for errors. I put all of these macros into a single header file that I can include, I have sometimes seen these called board support packages. They can sometime be entire libraries that abstract details of the hardware. In my case they are just simple header files as that is all I need for now.
Recently I decided to automate some of the work of creating these files as it can be very time consuming. This is the Awk script I ended up with.
#!/usr/bin/awk -f
{
if ($0 == "") next;
if ($2 == "PORTA") { port = "A"; }
if ($2 == "PORTB") { port = "B"; }
if ($2 == "PORTC") { port = "C"; }
if ($2 == "PORTD") { port = "D"; }
if ($2 == "PORTE") { port = "E"; }
if ($2 == "PORTF") { port = "F"; }
if ($2 == "PORTG") { port = "G"; }
print "#define " $1 "_PIN " $3;
print "#define " $1 "_TRIS TRIS" port "bits.TRIS" port $3;
print "#define " $1 "_LAT LAT" port "bits.LAT" port $3;
print "#define " $1 "_PORT PORT" port "bits.R" port $3;
print "";
}
All I need to do is write a space separated file in which each line contains the name I want, the port it is on and the number of the pin that it is attached to. Then this simple script generates the C code. This was for a PIC24F series micro, I have a slightly different script for a project involving a PIC32 which I may post later.
This makes creating BSP header files really easy, especially if you need to modify the pin assignments!
Iāve been working on a project thatās written in Python, it continuously communicates with some external industrial equipment. It will poll the status of this equipment 4 times per second and also sends commands to them when requested to. My job this week was to raise the update rate to 5Hzā¦. I needed to make sure I had enough time to do this!
I decided before doing anything I should profile the code to find out how much time the main loop needs to run and what methods take the longest time. That way Iād know if the code can support 5Hz and if not what I can do about it.
Once again the Python standard library comes to the rescue, theĀ cProfileĀ module will monitor the execution of your program and generate a report. Below is an example of how to use it.
import cProfile
cProfile.run("main()")
The next thing I did is write a simple bit of code that will print to stdout the current update rate of my application every second. Itās pretty much a Python port of the JavaScript libraryĀ stats.js.
from __future__ import division
import time
class stats(object):
def __init__(self):
self.msMin = 1000
self.msMax = 0
self.msTime = 0
self.fpsMin = 1000
self.fpsMax = 0
self.fps = 0;
self.updates = 0
self.startTime = int((time.time()+0.5)*1000)
self.prevTime = int((time.time()+0.5)*1000)
def begin(self):
"""Calling the method signifies the start of a frame
"""
self.startTime = int((time.time()+0.5)*1000)
def end(self):
"""Calling this method signifies the end of a frame
"""
now = int((time.time()+0.5)*1000)
self.msTime = now-self.startTime
self.msMax = max(self.msMax, self.msTime)
self.msMin = min(self.msMin, self.msTime)
#print "ms: %i (%i - %i)" % (self.msTime, self.msMin, self.msMax)
self.updates = self.updates + 1
if now > (self.prevTime + 1000.0):
self.fps = round((self.updates*1000.0)/float(now-self.prevTime))
self.fpsMax = max(self.fpsMax, self.fps)
self.fpsMin = min(self.fpsMin, self.fps)
print "stats: %i fps (%.i fps - %i fps)" % (self.fps, self.fpsMin, self.fpsMax)
self.prevTime = now
self.updates = 0
return now
def update(self):
self.startTime = self.end()
Simply add a call toĀ begin() to the start of your loop and a corresponding call toĀ end()Ā at the end of your loop. Now I get a nice counter that tells me how the code is performing. As I work on the code I can see how this affects the main loop performance.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking āAccept Allā, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.