Sunday, July 08, 2018

Google Home Mini - a mini review

As long as you don't have inflated expectations, this device does a pretty good job. But my initial problem was that I had higher expectations from Google :)

Expectation - I thought "Google Home" should be able to do a google search, like
OK google, do a google search for callisthenics
Sorry, I don't understand.

Reality - the device needs the prompt "tell me about", or "what is" - like
OK google, tell me about callisthenics.
According to wikipedia, callisthenics is.... (the first sentence only.)

OK google, what is a meteorite?
etc.

OK google, tell me more about callisthenics.
Sorry, I don't know how to help with that yet.

So, it can't read more than the first sentence.

It can tell jokes and do trivia etc, as described in various posts elsewhere.

OK google, tell me a joke.
(it tells a different one-liner every time.)

It needs an exact match for playing radio stations. For example,
OK google, play all india radio on tunein
Sorry, artists aren't available on tunein.

OK google, play All India Radio Classical on tunein
Sure, here's All India Radio Classical on tunein - (plays immediately).

Unfortunately, the music player in the API seems to buffer for quite a while, so currently, if we do
OK google, ask Radiosai to play bhajans
Playing radiosai bhajanstream - (plays after 100 seconds!)
We will try to fix this. It appears this is fixed now, by increasing the burst-size to 128000 on our server.

The radiosai action is a work in progress, but currently, things like this work -
OK google, talk to Radiosai
Sairam, welcome to radiosai etc...
Search for Climate Change
It appears your current device does not have a screen, so here's the first result... etc
(plays immediately).

OK google, increase volume to 50%
works when radiosai or some other agent is not having context.

The touch interface on the device has recently been enabled. So, long touch on either side makes it pause or resume, a tap on the left side makes it reduce volume, and a tap on the right side makes it increase volume. This was not immediately obvious.

It can do more complicated things, but within a limited repertoire. For example,
OK google, tell me how to make idlis
(reads out ingredients and steps one by one, saying let me know when you want to continue, etc.)
OK google, continue
Nothing is playing at the moment
OK google, next ingredient
(reads out the next ingredient.)
OK google, next.
(reads out the next ingredient.)
OK google, next.
(Reads instructions one step at a time, we have to say next for the next step.)
OK google, previous step
(Reads the previous instruction)
(Asks if we want an alarm to be set for required time, etc.)

Apparently there's a 640 character limit for each interaction from the device. So, reading out a large page would need user interaction like the above series of steps for the recipe. Wikihow works in a similar way.

OK google, wikihow
Hi, how's it going?
Bake a cake.
Hi, how's it going?
Wiki how to bake a cake.
I didn't get that, can you tell me what you were looking to do one more time?
(never got it to work.)

It can play news, weather forecast etc. - OK google, how is my day?

And for those with home automation systems, it can be set up to put on lights, play something on the TV with Chromecast, and so on.

So, some people will like it, especially if they memorize the phrases needed for the device to do the required action. But others will be frustrated by it. Examples can be seen in the comments in the article below,


Edit - and here is a "comprehensive list which is periodically updated" from CNET, of all Google Home commands - https://www.cnet.com/how-to/google-home-complete-list-of-commands/

Tuesday, July 03, 2018

packet sniffing wifi

Packet sniffing on a wifi network is a bit more complicated than using a wired network and a hub. Promiscuous mode alone is not enough -

https://osqa-ask.wireshark.org/questions/61656/promiscuous-mode-not-working

https://wiki.wireshark.org/CaptureSetup/WLAN#Monitor_mode

Then the packets have to be decrypted.

https://wiki.wireshark.org/HowToDecrypt802.11

For that, if using WEP, the WEP password has to be converted to the Hexadecimal key -
http://corecoding.com/utilities/wep2hex.php

change Google Home mini wifi settings without Google Assistant app

Trying out a Google Home Mini device. For setup, it needs the Google Home App on an Android or iOS device. For changing certain settings, it needs Google Assistant to be enabled on your phone. Since my current phone runs an earlier Android version than 5.0 which is the least required for Google Assistant, I am unable to change language of the device, unable to change the voice, and so on. Even changing the wifi network needs a different procedure than the one listed on google support.

So, my procedure, found by trial and error, was:

1. Open the Google Home app
2. Tap on the devices icon on top right corner.
3. If there is a card which says "your speaker name" speaker needs setup, and a setup link, you can use that.
4. Else, click on your device name, if it is listed, and the three dots on top right.
5. Choose reboot.
6. From the list of linked devices, unlink the device for which wifi needs to be set up.
7. Tap the back button to go to the home screen of the Home app.
7. Then the app would say that it has found one device which is ready for setup.
8. Click through to set up, including linking to an account and wifi settings.
9. When using a wifi network which was previously configured, it does not ask for the wifi password again.


Friday, June 29, 2018

ITR2 - paying income tax

1. Using the java based ITR2 utility needs openjfx in addition to installing java etc - on Mint/Ubuntu, sudo apt-get install openjfx

2. PAN / TAN of deductor = PAN/TAN of employer

3. importing - pre-filling the form - takes longer than a minute on the Acer laptop, takes 10 seconds on the i7 machine.

4. The re-calculate button of the java utility is not the same as validation. On clicking Save, validation errors pop up. So, use 'Save' to validate, and 'Save draft' to save partially completed form.

5. For the first time, I needed to pay tax. Payment is via https://onlineservices.tin.egov-nsdl.com/etaxnew/tdsnontds.jsp , Challan 280 at the bottom of the page. Netbanking and Debit cards are accepted. The type of payment is Self Assessment Tax.

6. The Challan serial number and other details like date are available in the pdf made available to download from the SBI post-payment screen. These have to be entered in the ITR2 form under self assessment tax payment made, and then submitted.

5. The Aadhaar based verification of return did not work for me - said that service is not registered with UIDAI. The bank account based verification worked.

Friday, June 22, 2018

blender z axis flip

Just a quick recipe for flipping an object in Blender -

  • Select object
  • Ctrl A (for Apply)
  • Choose Scale
  • Enter Z scale as -1
  • Ensure that scale checkbox is ticked under apply.


Wednesday, May 30, 2018

unhelpful error message - google groups

While adding users to a google group, came across this error - An error (#847) occurred while communicating with the server.

Apparently this has nothing to do with internet connectivity issues. These forum posts point to a bad email id in the submitted batch. Sure enough, there was a "blogger.com" email id in the batch which was causing problems for me. Removed it, all well. 

Tuesday, May 29, 2018

Google Apps legacy documentation

Looks like legacy Google apps users can't purchase extra drive storage - Can't purchase Google Drive Storage in legacy Google Apps Free edition - https://productforums.google.com/forum/#!topic/apps/z0tUAkQl_rM

Friday, May 11, 2018

Linux Mint Live CD / DVD

Some notes for Linux Mint Live CD / DVD


  1. username is mint, and no password.
  2. sudo does not ask for password.
  3. to take a backup, can do sudo cp -R /source/folder /destination/folder
  4. to switch between screens, Ctrl+Alt+F2 or Ctrl+Alt+F7 etc - need to press Fn also on Mac keyboard.

web hosting on github

A useful option for small static websites -

https://help.github.com/articles/using-a-custom-domain-with-github-pages/

https://pages.github.com/

The limits are quite generous - https://help.github.com/articles/what-is-github-pages/

"GitHub Pages sites are subject to the following usage limits:

  • GitHub Pages source repositories have a recommended limit of 1GB .
  • Published GitHub Pages sites may be no larger than 1 GB.
  • GitHub Pages sites have a soft bandwidth limit of 100GB per month.
  • GitHub Pages sites have a soft limit of 10 builds per hour."

Sunday, May 06, 2018

C++ programming - using fstream in a cross-platform manner

Some notes about making use of fstream in cross-platform code - 

Some interesting methods are discussed at
https://stackoverflow.com/questions/9739948/write-a-file-in-a-specific-path-in-c/40980510#40980510

In Visual Studio,
disable deprecation, use _CRT_SECURE_NO_WARNINGS - 

Configuration Properties >> C/C++ >> Preporocessor >> Preprocessor Definitions >>  _CRT_SECURE_NO_WARNINGS

A working code snippet - 

    char path[80];
    char foldername[80];
    sprintf(path,"homeuser/file.txt");
    sprintf(foldername, "homeuser");
    CreateDirectoryA(foldername, NULL);
    std::ofstream file(path); //open in constructor
    std::string data("data to write to file");
    file << data;

Friday, May 04, 2018

making an alexa skill

The Amazon Echo Dot, Google Home Mini, etc are inexpensive ways to listen to streaming radio without the need for interacting with a screen. The Echo can be used with Skills to make it easy to accomplish a particular task. Though in theory, radiosai is available on tunein and it should be possible to listen via tunein, of late, it doesn't seem to work. Alexa says, "I can't listen by genre on Tunein". So, tried to make an official Radiosai skill.

There was already a Radio Sai skill, but that one was missing AfriStream and AsiaStream. So, decided to try to implement this skill, with some improvements, as an official radiosai skill.

Changes in the user interface - the screenshots given here are no longer similar to Amazon's AWS console or the Skills console. Instead of uploading the sample utterances as a text file, I manually created the utterances in the Skill console using the wizard. Also added some confirmation before playing each stream, like


var message = 'Playing Bhajan Stream.';
this.response.speak(message);
this.attributes['stream'] = 'BhajanStream';
controller.play.call(this);

and also added a stop call to the AudioPlayer -

'AMAZON.CancelIntent' : function () { 
// adding the line below to stop the audio player 
controller.stop.call(this); 
////////////// 
var message = 'Good bye.'; 
this.response.speak(message); 
this.emit(':responseReady'); 
}

It looks like only the playModeIntentHandlers are active - the others don't seem to be called. Have submitted for being made available to the public.

Edit: Update May 11 -
1. Bug fixes by the owner of this repository, looks like the SDK had some changes so the zip file needed to be changed.

2. How to build an Alexa audio streaming skill from a template - YouTube video - lots of similar resources available

3. Audio player skill sample from Amazon, for multiple streams. 

Wednesday, April 25, 2018

Tuesday, April 17, 2018

Notes on compiling software lockin amplifier

Abbreviated notes from the software lock-in amplifier at https://github.com/hn-88/SoftwareLockin/

French lockin works on USB stick. Lubuntu 12.04

edited the pro files to add
QT += widgets

vumeter.h:40:25: fatal error: QtGui/QWidget: No such file or directory
on Mint 18.1

edit h files to make QtGui/QWidget QWidget

make clean
qmake multi.pro
make


error: ‘const class QString’ has no member named ‘toAscii’ - solved using

(was solved by install of package qttools5-dev-tools
more info here...) not used

QByteArray QString::toAscii() const
Returns an 8-bit representation of the string as a QByteArray.

This function does the same as toLatin1().

So, replaced in lockin.cpp and dockoutput.cpp

output has NaN

Edit: 20 Apr
ui_lockingui.h:13:29: fatal error: QtWidgets/QAction: No such file or directory
compilation terminated.
Makefile:406: recipe for target 'lockingui.o' failed
make: *** [lockingui.o] Error 1

probably have to find replace again?

Also QWidgets/QApplication

changed to QApplication etc - find replace QWidgets/ with nothing.

sudo apt-get --reinstall install libqt4-opengl-dev

Maybe if I upload the makefile?



Friday, April 13, 2018

USB to TTL link dump

A collection of links about communicating with serial control lines over USB - Arduino etc - 

Tuesday, April 10, 2018

bouncing emails in google groups

Maintaining google group by deleting bounced emails. And if needed, re-adding them. 

https://support.google.com/a/answer/7552660?hl=en

Edit: Users can reset their bounce status by going to https://groups.google.com/bounced?pli=1 or https://groups.google.com/a/example.com/groups/bounced?pli=1
next to Bounce Status, email status -> Reset bounce status. (which appears only if it is bouncing.)

Monday, April 09, 2018

Arduino IDE on Linux Mint

From https://playground.arduino.cc/Linux/Mint/
we should probably not use
sudo apt install arduino
because it is outdated or non-standard, and we should instead use the 64 bit binary from 
https://www.arduino.cc/en/Main/Software

Saturday, April 07, 2018

email slowdown and possible fixes

From March 24 or 25, our mailing list started having a lot of delays in email sending, especially to gmail.com. Found the following issues:

1. For some gmail emails, the server was trying the ipv6 address, and not able to reach it - like

Mar 25 09:34:15 krishna postfix/smtp[19788]: connect to gmail-smtp-in.l.google.com[2404:6800:4003:c03::1b]:25: Network is unreachable

Mar 25 09:34:28 krishna postfix/smtp[20163]: connect to ASPMX.L.GOOGLE.COM[2404:6800:4003:c02::1b]:25: Network is unreachable

This was probably due to a router change at the Studio.

Did this -
https://support.plesk.com/hc/en-us/articles/213398289-Specifying-Postfix-configuration-of-IPv4-IPv6-protocol-support
ie
adding the option:

inet_protocols=ipv4

to the /etc/postfix/main.cf Postfix configuration file. And then as root,

# postfix reload
# service postfix restart

That worked, the emails went out. But the email sending rate was only around 1000 emails per hour, as reported by
# qshape incoming active deferred

2. A lot of mails were being deferred instead of bounced by gmail, OverQuotaTemp.
cat  /var/log/mail.log | grep OverQuotaTemp | wc -l
5878
PB unconfirmed those emails using
cat /var/log/mail.log | grep OverQuotaTemp | grep 'to=' | grep -o '[[:alnum:]+\.\_\-]*@[[:alnum:]+\.\_\-]*' | sort | uniq -i

Then also for bouncing emails, like
cat  /var/log/mail.log | grep "does not exist"
cat  /var/log/mail.log.1 | grep "does not exist"
cat  /var/log/mail.log.1 | grep "553 Mail from 111.93.16.162 not allowed"
cat  /var/log/mail.log | grep "status=bounced"
cat  /var/log/mail.log.1 | grep "status=bounced"

3. Mails were still going out slowly, with the usage on the internet port being like

Next try was to speed up sending to gmail.com domain, since the other emails were going out OK. Then, added these two lines to /etc/postfix/main.cf - 

maximal_queue_lifetime = 2d
default_destination_concurrency_limit = 100

decreasing lifetime from 5d to 2d and increasing concurrency limit from 20 to 100. That seemed to improve things - the outgoing rate went up to almost the peak rate - 

and from the next day, the emails were going out like









Thursday, April 05, 2018

notes on startup / shutdown times

On a machine with dual boot,

Time taken for Windows 7 to boot, open firefox and open youtube.com - 3:30 minutes.
Time taken for Linux Mint 18.3 to boot, open firefox and open youtube.com - 1:15 minutes.
Similarly, Windows takes 40 seconds to shut down, while Linux shuts down in less than ten seconds.
Equivalent of Hotspot Shield, if you want to watch something which is blocked - have installed PureVPN extension for both Chrome and Firefox...

Linux vs Windows 7 brief speed test

N's Lenovo B640 laptop had become old and slow. Tried dual booting with Linux Mint, found quite an improvement. 

Time taken for Windows 7 to boot, open firefox and open youtube.com - 3:30 minutes.

Time taken for Linux to boot, open firefox and open youtube.com - 1:15 minutes.

Similarly, Windows takes 40 seconds to shut down, while Linux shuts down in less than ten seconds.

Thursday, March 29, 2018

finding ip ranges via ASN

To obtain all the IP ranges of an ISP or large organization, got a procedure from this quora post -

https://www.quora.com/How-can-I-obtain-a-list-of-IP-addresses-owned-by-a-specific-company-I-would-like-to-provide-a-targeted-offer-to-site-visitors-if-they-work-at-a-certain-company-I-would-like-to-get-a-list-of-the-IP-addresses-that-this-organization-owns


https://www.peeringdb.com/net/1903 has Airtel's ASN.

Then, we can use that ASN in this whois query -

whois -h whois.radb.net -- '-i origin AS9498' | grep -Eo "([0-9.]+){4}/[0-9]+" > airtel.txt
whois -h whois.radb.net -- '-i origin AS9829' | grep -Eo "([0-9.]+){4}/[0-9]+" > bsnl.txt

Wednesday, March 28, 2018

boot from grub - link dump

https://www.linuxquestions.org/questions/linux-software-2/booting-windows-from-the-grub-prompt-275446/

root (hd0,0)
makeactive
chainloader --force +1
boot

But grub 2 is different.
https://www.linux.com/learn/how-rescue-non-booting-grub-2-Linux

grub> set root=(hd0,1)
grub> linux /vmlinuz root=/dev/sda1
grub> initrd /initrd.img
grub> boot

https://unix.stackexchange.com/questions/77263/use-grub-rescue-to-boot-from-windows-xp-partition-cd-or-usb

set prefix=(hd1,1)/grub
set root=(hd1,1)
insmod normal
normal

https://www.aioboot.com/en/boot-windows-grub2/

from grub rescue prompt,
search -s root -f /NTDETECT.COM
drivemap -s hd0 $root
ntldr /ntldr
boot

https://www.gnu.org/software/grub/manual/grub/grub.html#DOS_002fWindows

parttool (hd0,1) hidden-
parttool (hd0,2) hidden+
set root=(hd0,1)
chainloader +1
parttool ${root} boot+
boot

https://www.aioboot.com/en/boot-windows-grub2/

http://forums.justlinux.com/showthread.php?153121-Fun-with-GPT-partitioning

unable to make XP boot from a cloned volume on Intel Mac

Just a few lines of notes - trying making other partitions hidden to make XP boot - doesn't work, since partition is GPT, grub says hidden - unknown argument or whatever.

using dd to clone a usb drive

From
https://www.garron.me/en/bits/convert-store-copy-bootable-usb-iso-file-another-usb.html

Tuesday, March 27, 2018

Linux Mint 18.1 not booting - solved

Linux Mint was not booting into graphical mode. It was not even dropping me into an emergency shell - a dialog box about not being able to connect to upstart would appear, your session lasted only 10 seconds etc, and the window manager would restart. Initially I thought this was due to some problem related to booting as in my previous post. But then, saw this post on the Linux Mint forums. So, hit Ctrl Alt F2 to get a shell, (in my case, fn+Ctrl+Option, since this is a Macbook), did
  apt remove virtualbox-guest*
and rebooted OK. 

Monday, March 26, 2018

link dump - ALSA etc - for software lock-in amplifier

ALSA tutorial for beginners - 2004 - http://www.linuxjournal.com/article/6735?page=0,1


Checking the code and compiling from https://www.av8n.com/physics/lockin.htm

http://www.qtcentre.org/threads/53452-QtGui-QApplication-No-such-file-or-directorty

QApplication and Qwidgets derived classes are in widgets module in Qt 5 so to fix that you need to add QT += widgets in the .pro file and run qmake and also use #include <QApplication> instead of #include <QtGui/QApplication> (and the code becomes compatible with both Qt 4 and 5), you can read more here

Or download 10.04,
and
https://help.ubuntu.com/community/Installation/FromUSBStick#Install_and_run_Startup_Disk_Creator_alias_usb-creator

Thursday, March 22, 2018

link dump for triple boot of Windows, Linux and MacOS on Macbook

1. https://lifehacker.com/how-to-run-a-portable-version-of-windows-from-a-usb-dri-1565509124


https://medium.com/@manujarvinen/setting-up-a-multi-boot-of-5-linux-distributions-ca1fcf8d502

2. Brief notes: Using rEFInd, need to allow drive to spin up for it to be visible on refind.

usb drive not seen with refind.

Windows XP installer did not allow installation to partition which was created after the mac partition, so creating a new partition by moving the mac partition - 8 hours!

3. EFI fix - https://apple.stackexchange.com/questions/57597/how-to-fix-broken-efi-partition

https://www.kubuntuforums.net/showthread.php/43221-GRUB-2-A-Guide-for-Users/page15?p=379352#post379352

Tried gdisk -> Advanced -> H

Finally. Install Mint alongside other partitions.

4. https://www.tecmint.com/command-line-tools-to-monitor-linux-performance/

5. EFI - Created with Linux mint install graphical using 200 MB at beginning.

Edit: 7 Nov 2019 - https://www.intowindows.com/how-to-create-live-usbcddvd-of-vistaxp/


Edit: 2 Jan 2021 - Possibly a portable Win10 using WintoUSB may be the easiest option, for Windows 7 and higher versions of Windows - the Macbook is supposed to boot from CD if we press and hold the C keyhttps://en.wikipedia.org/wiki/WinBuilder#Actively_developed_projects


restoring to a different path

 A link dump on restoring a cloned disk to a different path - 



Wednesday, March 21, 2018

recovering after overwriting EFI partition

Tried to install Windows XP on the Macbook running OS X 10.6 and Linux Mint 18.1 dual boot. Though a new primary partition was created at the beginning of the drive, Windows XP refused to install on it, saying there are too many partitions.



In the process, the EFI boot partition was overwritten. So, the machine would not boot. Tried creating a refind boot USB drive - that showed up the Mac and Linux boot loaders, but did not boot either of them - the Linux boot ended in an emergency shell, and the Mac boot ended with the Mac apple turning into a cross, and not booting.

Googled various options, and thought the easiest way would be to do another Linux install. Made another Linux Mint installable USB drive by doing dd of the Mint 18.3 iso to a 16 GB drive, recreated an EFI partition using the installer's GUI partitioning tool, installed the 18.3 to another partition created in free space, and after install, the 18.3 and MacOS were successfully booting.

The original Linux Mint 18.1 was still not booting - dropping into emergency shell. 'Welcome to emergency mode! After logging in, type "journalctl -xb" to view system logs, "systemctl reboot" to reboot, "systemctl default" to try again to boot into default mode.'



journalctl -xb showed that the reason for not booting up was that it was not able to mount /boot/efi with UUID - the UUID had changed, of course, since the boot partition had been re-created. So, just booted into the new 18.3 Linux install, mounted the 18.1 volume, sudo nano edited the /etc/fstab with the UUID from the 18.3's /etc/fstab, and then rebooted - all OK.

Here are some of the things I googled and found - something like rough notes -

enabling bios mode
https://superuser.com/questions/1133040/unable-to-boot-into-windows-10-with-refind-solved/1133052
Ctrl R for safe boot into OS X
https://kb.wisc.edu/helpdesk/page.php?id=7197



Saturday, March 17, 2018

Unified Threat Management - UTM devices, proxies etc

In the context of an outage of our Cyberoam device, and the general decrepitness of the college proxies, I took a look at some available options, tuning etc.

https://www.quora.com/Which-is-the-best-Open-Source-Unified-Threat-Management-System-UTM-in-the-market

mentions ClearOS

http://jonmoore.duckdns.org/index.php/network-security/32-open-source-utm

reviews pfsense , untangle and sophos. He has an additional VPN requirement.

Comodo offers a free download.

https://www.google.co.in/search?q=set+up+a+unified+threat+management+appliance+with+open+source+software

For squid tuning, cache size etc,
https://forum.pfsense.org/index.php?topic=24429.0

where a user suggests, for an admin who has trouble with 70 users,

 I recommend use 10KB to 16KB(thumbnail picture size) for object size.
On restart COSS contents will be lost(developent still on progress for this issue)

for your memory issues:
squid/lusca would use 10MB per GB of total cache(when full).
http://wiki.squid-cache.org/SquidFaq/SquidMemory#How_much_memory_do_I_need_in_my_Squid_server.3F

If your system starts to use SWAP file(due to lack of RAM) then it will definitely slows your internet.
Squid/lusca starts to grow Page faults it also affects performance.

You might need to consider changing your cache_mem and give them to your OS.
This FAQ would help you.
http://wiki.squid-cache.org/SquidFaq


Tuesday, March 13, 2018

temporary router

PB sent me his configuration changes when he put in a temporary router -

1. Editing /etc/network/interfaces to give our mail server a public id (earlier it was in the DMZ)
2. Physically connecting the server with LAN cable to one of the ports of the router.
3. Going to NAT Access Control under Network Options on the router's config page, to disable NAT for the mail server. 

Sunday, March 11, 2018

lines seen on camera capture with new SDK

With QHYCCD's new SDK, lines were seen on captures. But on further study, found that the lines were seen when phone LED or LCD screen of computer is used as illumination, not otherwise.

So this is probably due to the effect of the rolling shutter + the repetition rate of the illumination.

We checked with sunlight - no lines - and with SLED illumination - no lines. So we are probably all good.

Tuesday, March 06, 2018

Windows executable slower

Found that an opencv cross-platform executable was running slower on Windows - compiling in Release mode instead of Debug mode did not improve this. Most probably due to the DFT algorithm, which might not be optimized on Windows. There were multiple DFTs called within the image refresh loop. The linux binary ran at 100 fps for 16 bit 320x240 images and 200 fps for 8 bit 320x240, but the windows exe was limited to 64 fps for both 16 bit as well as 8 bit. Linux was running on an i7 Macbook running Mint 18.1, Windows 8.1 was running on an i5 I believe.

Edit - my analysis above seems to be wrong - the code only had the Hilbert transform (and hence the DFT) on press of s key - and the fps was low even when no keys were being pressed. Some other bottleneck. Display driver?  

QHY SDK - Windows and Linux

Found the answer to my query to the QHYCCD helpdesk in November - the difference between the behaviour of Windows software which uses the Windows QHY SDK, and software built using the Linux SDK (and between different versions of the SDK!) are due to different implementations of the SDK.

My query was:

....my question is about frame to frame variations.

For example, I closed the lens cap and took two snapshots. Gain=5, Exposure time = 20 ms. I find that the pixel values are like:

Frame1: 3168   3216   3184   3184 etc
Frame2: 3232   3152   3248   3184  etc

So when i subtract Frame 2 - Frame 1, I get
64  -64  64 0 etc. with a max value of 256.

And this difference increases when there is light falling on the camera.

Is there any way to reduce this frame to frame difference? Any way to reach the 6e performance?

Also, when reducing gain, I find that the image gets saturated at a value below the full 16-bit max value of 65535. For example, with a gain of 5, the saturation happens at an intensity of 27776.

The reply was that the 6e error is the readout noise. The rest of the noise is probably shot noise

 The gain values are the numbers entered in Sharpcap (latest version). I have checked with two different QHY5Lii-M cameras. On both, if gain is reduced below 30, saturation occurs below 65535 (in 16bit mode - in 8bit mode, below 255).

For example, as mentioned before, with a gain of 5, whether the exposure is 5 millisec or 5 sec, the max value is only 27776.

But when I code my own capture, using the SDK at
https://github.com/qhyccd-lzr/QHYCCD_Linux
there is a difference - if I change the parameter CONTOL_GAIN
with SetQHYCCDParam(camhandle, CONTROL_GAIN, camgain);
even for value of camgain=1, I am able to see saturation at 255 for 8 bit mode. So, I could use this for my work. Maybe Sharpcap uses a different set of numbers? or a different parameter? as gain. 


The QHY team did not reply, but I found that the Windows and Linux SDKs have a different range for the Gain parameter, and probably for other parameters as well!  The Linux SDK (Software Development Kit) and the Windows SDK are developed by different teams. So, the same functions have different implementations! For example, gain goes from 1-100 in the Linux SDK we tested. But gain goes 1-480 in the latest Windows SDK.

Sunday, March 04, 2018

cross platform issues

In order to get the OpenCV code using the QHY camera SDK - originally written on Linux - running on Windows by compiling it with Visual Studio, the following items had to be done.

  1. Install the latest Visual Studio Community edition (v. 15, Visual Studio 2017). OpenCV's latest binaries only work with v14 and v15, and if we use some other version of VS, we would have to recompile opencv, which would be a pain.
  2. Install the latest QHY SDK from http://www.qhyccd.com/SWHIST_SDK.html - the latest version of the SDK has the lib files, h files and so on in addition to the dll binaries. Currently the latest version is at the bottom of the page!
  3. Install the latest version of OpenCV for Windows from sourceforge, following the instructions at https://docs.opencv.org/2.4/doc/tutorials/introduction/windows_install/windows_install.html
  4. The instructions on how to build an opencv application, https://docs.opencv.org/2.4/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.html#windows-visual-studio-how-to
    is reasonably similar to what we need to do, except for the fact that it would be better if we create a new property sheet called common and save it for future use as mentioned in the next point below - VS15 does not recommend .user property sheets.
  5. In a newly created property sheet (called common, for reuse), add the additional include directories, linker files etc as mentioned in the documentation on point 4 above. Here, we need to add the QHY SDK includes and dlls also. The opencv libraries are now distributed as a single file, opencv_world.lib and not the multiple lib files as in the documentation above. So, in short,
    VC++ directories -> Include
    Linker General -> Additional Library directories
    Linker Input -> names of the lib files in Additional Dependencies 
  6. The .cpp files need to have ifdefs for linux and windows standard headers separately. Code can be seen at https://github.com/hn-88/ASKlive/blob/master/ASKlive.cpp
  7. For the C function sprintf to work, the following pre-processor directive has to be added - C++ -> Preprocessor - > Preprocessor definitions -> add _CRT_SECURE_NO_WARNINGS
  8. In order to copy over the required DLLs, the following post build event has to be added -
    xcopy /y /d "D:\qhy\*.dll" "$(OutDir)"
    xcopy /y /d "$(OPENCV_DIR)\bin\*.dll" "$(OutDir)"

    It is safer to copy to the executable's directory, since there is quite a bit of confusion about copying to system folders - http://www.forceflow.be/2012/04/04/the-3264-bit-dll-confusion-on-windows-64-bit/
  9. Arrays have to be pre-assigned sizes - can't be assigned sizes at runtime as with GNU C compiler. 
Edit 3 June 2018 - 10. Added this line of code to prevent the "exe has stopped working" Windows dialog box on exit - 
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
via stackoverflow, with additional documentation at msdn

Raspberry PI configuration link dump

  1. Impressive - The Raspberry Pi 3 boots up in 25 seconds to Desktop. 10 seconds to open Chromium browser. 25 seconds to load a google spreadsheet. Overall, faster than my AMD64 Windows XP laptop from 2009. :)

  2. Older version of RPi (Pi2?) - good for playing local videos - was pleasantly surprised to find that I could just put in the same micro-SD card which was running Raspbian 9 into a SD-card adapter and put it into the older Pi, and it booted and ran fine - did not need any reinstall.

    It is good for playing local videos. It could play 2 windows with 2 instances of VLC running local copies of 360p videos without any problems - 35% CPU for each instance, MP4 and DIVX respectively. But it could not play videos reliably over the network. Also, web browser Chromium takes a very very long time to open, web pages crawl to load. Probably because of the low RAM.

    But I can use it as a video player, with a status message at the bottom or something like that.

  3. lspci -vvnn | grep 802

    lsusb does not show it when driver is not installed.

  4. Cloning RPi with dd - https://www.raspberrypi.org/forums/viewtopic.php?t=46911
    sudo fdisk -l
    sudo dd bs=4M if=/dev/sdc | gzip > /home/your_username/image`date +%d%m%y`.gz
    sudo gzip -dc /home/your_username/image.gz | dd bs=4M of=/dev/sdc


  5. Enabling monitoring on RPi wifi - https://raspberrypi.stackexchange.com/questions/36747/enable-monitoring-mode-for-rtl8188cus-via-usb-on-raspbian

  6. How to loop in VLC - https://forum.videolan.org/viewtopic.php?t=78723 - and subtitles in vlc playlist maker.

  7. Adjusting Overscan on the RPi - https://retropie.org.uk/forum/topic/2371/using-composite-video-can-t-see-everything-on-the-screen/16

  8. Raspberry PI model comparison - http://socialcompare.com/en/comparison/raspberrypi-models-comparison

  9. Shortcut to edit text file -  Exec=leafpad %U /home/pi/file.txt

Saturday, March 03, 2018

securing lighttpd

Brief notes on securing lighttpd, the light-weight web-server - 

https://www.packtpub.com/mapt/book/networking_and_servers/9781847192103/7

# deny access to all files below a certain path
$HTTP["url"] =~ "/certain-path/" { url.access-deny = ("") }
# deny access on all jpeg images to the Google bot
$HTTP["useragent"] =~ "Google" { url.access-deny = (".jpg") }
# deny access by referrer
$HTTP["referrer"] !~ "^($|www.ourhost.com)" {
url.access-deny = ("")
}

under mod_access

and also passwd auth.

Friday, March 02, 2018

QHY camera glitch

After removing the new SDK files from Linux Macbook in order to test the camera again with the old SDK, the QHY5L-ii camera was not being recognized on the Linux machine at all. Both cameras, on both USB ports, LED does not light up, no dmesg messages either.

Tried on another Linux machine - Acer running Ubuntu 16 - without any drivers installed - again, no dmesg messages.

Tried changing the USB cable - then a dmesg message was seen, detecting on a 'slow port'. Tried on the Macbook again after reinstalling the new SDK, now it was showing dmesg messages as well as LED lighting up - detected OK. Changed back to the original USB cable - everything still OK.

So, probably a combination of hardware and firmware issues.