How to configure a new network interface in Android - android-networking

I am trying to configure a new network interface on Android tablet (v3.2).
From terminal application I can
"ifconfig eth0 192.168.11.14 netmask 255.255.255.0 up"
and everything works fine (ethernet cable is connected trough USB-Ethernet dongle)
I want to make this configuration persistent, but it looks like there is no 'interfaces' file in Android.
Where is network configuration file located? Do I need to create new one? Where?
Thanks,

yet another late answer... scoured the internet and couldn't find any decent answer until I checked out /etc/init.sh ...
I'm using an Android Oreo vmware image for testing purposes and here are the steps that I used to add static IP to Android on boot:
Open Terminal Emulator (if not present install from Play Store)
type su
type vi /etc/init.sh
type i
look for function do_init()
before the closing curly brace (}), type post_init_network
create new line after the closing curly brace (}), type
function post_init_network()
{
ifconfig 192.168.63.122/24 up
}
change the ip and subnet as needed...
press :wq! to save and exit vi
power of and power on Android.
To check Static IP:
open Terminal Emulator again after power on, type su, then type ifconfig
NOTE: I encounter this issue where I can't get an IP from NAT network using 2 interfaces where the first interface is set to static IP and the other DHCP, just power on and power off Android until you can get an internet connection.

Sorry for the really late answer. This is more for future reference.
If your ROM supports init.d scripts, try writing one for this. Put the file in /system/etc/init.d/, change its access mode and owner/group to 0755 and root:root, respectively.
Your command will be run at every boot, effectively making it persistent.

Related

Is there a library for MSR605X that works with Raspberry Pi?

I have been trying to locate a working library for the MSR605X magnetic card reader/writer. At time of writing, I have tried five separate libraries. Only two of these were explicitly for the 605X the other three were for the older 605. All the libraries I have tried either did nothing at all or errored before completing a command (can't figure out the errors either).
I am running Raspberry Pi OS 32 bit on a Raspberry Pi 3 B+ the MSR605X communicates via a USB connection.
So far the library that seems to be most complete is: https://pypi.org/project/msrx/
However, I can not get this library to read or write (either nothing happens or I get a Serial exception "cannot reconfig port).
Any help or links to documentation for this reader is welcome.
EDIT: Adding the commands ran with the above library
msrx -D /dev/input/event4 read
msrx -D /dev/input/jso0 read
The -D is to specify the device path (default is /dev/ttyUSB0 which doesn't exist on my system). I obtained the above two paths by searching for USB serial devices then matching the search result to the device ID which I obtained from lsusb.
Running these commands results in a serial exception (could not reconfig port) which I assume means that I have the wrong device path. I have also checked for any tty* device paths that are changed when I plug in the reader. I consistently get a permission denied error whenever trying to run the above commands with a tty* device path (I am root on this system).
msrx author here — MSR605 requires an external 9V power injected into its cable (via the barrel jack port), otherwise it won't power up properly.

Why is VSCode "Unable to open Extension. An unknown error occurred."?

This is my first time installing and using VSCode, and when I tried installing Prettier extension, it let me peek quickly at the extension page before closing it and displaying this notification (Screenshot attached):
Unable to open 'Extension: Prettier - Code formatter': An unknown error occurred. Please consult the log for more details..
VSCode screenshot: Notification at bottom right
It's doing this with all other extensions. Searched for a solution but found nothing applicable.
Why is this happening and how to fix it?
It happens that, this is a problem with the Egyptian ISPs' default DNS servers, which are most probably blocking some of Microsoft servers.
The solution (in case you live in Egypt):
clear DNS cache using ipconfig /flushdns command on Windows cmd (For Other OS).
change the default DNS servers in your router settings to Google's 8.8.8.8 & 8.8.4.4 (or Cloudflare's 1.1.1.1 or any other DNS server you trust).
restart VSCode and try installing extensions.
Hopefully, everything will work fine by now.
Check this Github issue for more insight.
It probably is because of the certificate check.
Below solution works for me in CentOS 7 (Linux).
Step 1. Change the file /usr/share/applications/code.desktop
Open the file /usr/share/applications/code.desktop,
then modify the Exec value with adding --ignore-certificate-errors before %F:
Exec=/usr/share/code/code --unity-launch --ignore-certificate-errors %F
Save the file with typing sudo in the begining.
Step 2. Close all windows of vs code instances.
Step 3. Back to the terminal, use below command to open VS code:
code --ignore-certificate-errors
Step 4. Click extension button in the left side bar.
Click any extension like "Ruby" by Peng Lv, if the images in the Details page can be seen successfully, perhaps the issue is solved.
Step 5. Try to continue to install the extensions you need.
Just enjoy! May it be helpful for you.
in ubuntu go to settings -> wifi -> click on gear icon -> IP4 -> dns input
and put
8.8.8.8,8.8.4.4
and click apply,
to DNS Resolver Cache open terminal and type:-
sudo systemd-resolve --flush-caches
sudo systemctl restart systemd-resolved
restart your device
For windows
cd "C:\Users\<user>\Appdata\Local\Programs\Microsoft VS Code"
code.exe --ignore-certificate-errors
The solution
clear DNS cache using command on Windows cmd:
ipconfig /flushdns
change the default DNS servers in your router settings to Google's:
8.8.8.8 , 8.8.4.4 >> for IPv4
2001:4860:4860::8888 , 2001:4860:4860::8844 >> for IPv6
This link will guide you how to change the DNS server in windows and mac:
https://www.ionos.com/digitalguide/server/configuration/how-to-change-dns-server/
restart VSCode and try installing extensions.
If you're in a corporate network and it's locked down the one last resort is to manually download the VSIX from the website on a domain that will allow it and then copy over the VSIX and install it.
I got this "XHR failed" error in Visual Studio Code.
So I changed my network settings to use Google Public DNS (instructions)
Finally following instructions (by mohamed-mokhtar) solved for me:
Go to : Control Panel\Network and Internet\Network Connections
Choose your connection network and ( right click on it then choose properties )
Select " Internet Protocol Version 4 (TCP/IPv4) and then click on properties in the bottom of this section
At General section click on " Use the following DNS Server address : "
Make " Preferred DNS server : 8.8.8.8 " (if you face a problem check this)
Make " Alternate DNS server : 8.8.4.4 "
Restart VS code
referring to #Seif A. answer
The solution (in case you live in Egypt)
clear DNS cache using command on Windows cmd:
ipconfig /flushdns
change the default DNS servers in your router settings to Google's:
8.8.8.8 , 8.8.4.4 >> for IPv4
2001:4860:4860::8888 , 2001:4860:4860::8844 >> for IPv6
restart VSCode and try installing extensions.
I faced the same problem while adding new extension in vs code.
I Recognized the problem within the ISP in Egypt, so I changed the DNS in My router to Google DNS Providers , and it works perfectly
Just install a VPN like betternet or any other VPN software and change the country to the USA or try other countries.
In my case I was need to disable work VPN to download extension

Uploading code from platform IO to esp32

I'm sorry for that stupid question but I really can't find what I need.
I made a code to use a ESP Wrover 32 with PlatformIO/VScode and I need to upload the code to the ESP32 (connected to the computer using USB) but I can't find how to select the right USB port to upload the code.
The error is :
Please specify 'upload_port' for environment or use global
'--upload-port' option.
I tried to use the command lines but nothing works.
How can I upload my code ?
Thanks
To find the USB port: Hit WindowsKey-X, select Device Manager, plug in the device and observe what's listed under Ports (COM & LPT) - the one that just appeared has the port in brackets (COMn).
Then in platformio.ini in your PlatformIo initialised project folder, you specify the port as a line under the platform section (env: square brackets line): upload_port = com9 or whatever you got from Device Manager.
I hope this helps.

RPi2 UART Setup & Operation Issues

I'm currently busy with my masters project which involves setting up comms on UART between a Raspberry Pi Model 2 B V1.1 and a Pixhawk Flight Controller using Mavlink protocol.
The first step is, of course, to get the UART set up and working. I'm not one to run after help at the first sign of a problem. I have been struggling with this for days and it's forced me to doubt the purpose of my existence more than once. I feel stupid and frustrated. Please see if you can provide any assistance.
My first resource was this tutorial, which should be relatively straight forward:
http://ardupilot.org/dev/docs/raspberry-pi-via-mavlink.html
The tutorial simply installs all the necessary packages and dependencies, as well as sets up the UART. I followed the steps to disable OS use of the serial port through raspi-config, however after attempting to test the connection I get an error:
[Errno 2] No such file or directory: '/dev/ttyAMA0'
Which is very strange. So after disabling and enabling OS use of serial port through rasp-config a few times and checking, every time I disable it, the /dev/ttyAMA0 file disappears. Now how the hell is anything supposed to work on the UART if disabling OS use of the UART removes that file!? Nevertheless I powered through. I enabled OS use of the serial port, which leaves the ttyAMA0 file right where it is and followed another suggestion, which is to change the /boot/cmdline.txt and remove all reference to ttyAMA0, as shown in the following link:
http://www.raspberry-projects.com/pi/pi-operating-systems/raspbian/io-pins-raspbian/uart-pins
This seemed to work alright. I could now initiate comms between the RPi and the Pixhawk flight controller and get some information that looked correct. Then the black magic started. The next day I tested the connection and it consistently spat out complete rubbish. But Nothing changed since the previous day. Somewhere I must be missing something. I followed all the same tutorials and steps attempting to get the more positive results I got the previous day. However that only led to more erratic behaviour. When connecting the serial lines to my Pixhawk Flight Controller, the keyboard/mouse seems to get interrupted momentarily every now and then. Everything just went backwards. I have already reinstalled Raspbian Jessie in a desperate attempt to get things to work.
Here are a few things I suspect could possibly contribute to the problems:
Baud rate not correct (to communicate with my Flight Controller baud rate needs to be 57600). Best way I've found to set this baud rate is to append "init_uart_baud=57600" to /boot/config.txt/. I have also read about other ways such as appending a line to /etc/crontab. Any suggestions?
Pixhawk miraculously and sporadically refused to communicate back with RPi.
Any assistance will be appreciated. Thank you.
SOLVED:
Looks like a known bug in the latest raspbian, easy to fix though.
These need to be done as the root user.
Disable "serial console" through GUI-preferences or "sudo raspi-config." Then reboot the pi.
Then change the following line in the file /boot/config.txt at the bottom of the file from:
enable_uart=0
to
enable_uart=1
Disable the ModemMonitor service by running the following command as root:
systemctl disable ModemManager.service
Then add youself to the dialout group, just to be sure you have the required permissions on the serial port:
adduser pi dialout
That should give you unrestricted proper access to the serial port.
Resources:
[url]https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=148515[/url]
and
[url]https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=82779[/url]
I had researched this for days now and troubleshooting all the readings listed on Google sites. I solved the serial UART settings for connecting my RPi3 Model B (typed at command line the following:
`cat /proc/cpuinfo`
to find my Pixhawk hardware info.)
FYI: You must be root when working with mavproxy so, sudo su
or sudo -s
Also, you must be a member of the dialout group, so do this at CMD line:
sudo usermod -a -G dialout root (enable root user!)
Do all the RPi regular stuff:
sudo apt-get update && sudo apt-get upgrade and sudo rpi-update.
Did all as outlined in the Ardupilot website. I did NOT use the
"apsync-rpi". (I used the 2017-03-02-raspbian-jessie.img.) at here
On my RPi3, using $uname -a: results--> Linux raspberrypi 4.4.50-v7+
My $sudo nano /boot/config.txt file has one change at bottom of file;
THIS statement: enable_uart=1 (has a good side effect of forcing the
core_freq to 250 which reduces poor signal frequency)
Important discovery: so the articles state that RPI3 UART and tty settings have changes. (link here)
What I have discovered after much ado is this for my sudo nano /boot/cmdline.txt file:
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 etc.,.
-Notice I am not using ttyS0 in the /boot/cmdline.txt file. I tried the ttyS0 a dozen times and it never worked properly. For some reason, I am not able to explain it at this time, although the console=/dev/tty1 works if written in the /boot/cmdline.txt file.
Make sure you have the wiring correct between your RPi and the Pixhawk.
Telem 2. Also set the correct parameters in Mission Planner as I
have;
Go to CONFIGTUNING->STANDARD PARAMS; (my settings)
-The Serial0 baud rate(SERIALO_PROTOCOL) is: 115200
-The Console protocol selection(SERIAL0_PROTOCOL) is: MAVlink1
-Telem1 baud rate(SERIAL1_BAUD) is at: 115200
-Telem1 protocol selection(SERIAL1_PROTOCOL) IS MAVlink2
-Telemtry 2 Baud rate(SERIAL2_BAUD) is 921600
-Telemetry 2 protocol selection(SERIAL2_PROTOCOL) is MAVlink1
The RPi and pixhawk communicate at 921600 baud rate.
-Once I get the RPi3 powered up with it's own +5/VCC source and connect to my MP with a 3.0 USB cable from my PC-Windows10PRo, (okay, I have Arch and Debian Linux distros and Apple OSes too!) I enter:
`mavproxy.py --master=/dev/ttyS0 --baudrate 921600 --aircraft Plane`
It works for me!
Happy experimenting and flying!

Raspberry webserver change website name

In my browser i can type 192.168.178.33:8000 to access the webpages on my raspberry or
http://raspberrypi:8000/
Somewhere must be set that the web browser translate http://raspberrypi:8000/ into 192.168.178.33:8000 I tried to find a nameserver but I've no idea what or where I can change this
Is there a simple way to change
http://raspberrypi:8000/ into http://whateverIWantHere:8000/
You can edit your hosts file. The location is different for each OS and may also be different for different versions of the OS. Note that you only need to do the changes on the computer where you want to translate it.
Windows 10:
C:\Windows\System32\Drivers\etc\hosts
Linux/Raspbian:
/etc/hosts
Add the following line to the end of the file:
192.168.178.33 raspberrypi
You may have to restart, I'm not sure if the changes will apply immediately. And you can now type 192.168.178.33:8080 in your browser.