I want send AT commands to USB modem connected to raspberry pi. I have found some helps mentioning that USB modem is usually connected as ttyACM or ttyUSB device, but I have no ttyACM or ttyUSB device. I have devices from tty1 to tty63, but I do not know how to identify which one is used by the modem.
I have tried to find the device by storing devices list with the modem unconnected and then compare device list after the modem is pluged in:
ls /dev/ > dev_list_1.txt
(plug the modem in)
ls /dev/ | diff --suppress-common-lines -y - dev_list_.txt
returns to me:
bsg <
sda <
sg0
I have tried to connect the modem with cu tool:
sudo cu -l sda
sudo cu -l sg0
but both returns:
cu: open (/dev/sg0): Permission denied
cu: sg0: Line in use
So I tried also use minicom and configure serial communication to /dev/sg0 or /dev/sda but it does not work either.
So I think I need to find right tty device used by the modem to be able to communicate with it. But how to find it?
You can look for /sys/class/tty/*/device entries and ignore all the links that points to serial8250 since those are not USB devices.
With shell script:
for device in /sys/class/tty/*/device
do
case $(readlink $device) in
*serial8250) # e.g. ../../../serial8250
;;
*) # e.g. ../../../1-3:3.1
echo $device | rev | cut -d/ -f2 | rev
;;
esac;
done | sed 's#^#/dev/#'
which produces
/dev/ttyACM0
/dev/ttyACM1
/dev/ttyS0
with my phone connected. You might get more than the usb devices (e.g. ttyS0) but at least this should give you all the usb serial devices the kernel know about (and if the device does not populate /sys/class/tty/ it almost certainly is not a serial device).
This is based on the list_ports function logic in the libserialport library.
Related
I've a sd card on my phone, it's some type of freez , I could not do any thing on it , when I remove files , it removes and then come back to what it was , it's not formatting.
it freeze and nothing works on it .
What I've tried so fa :
1- tried diskpart in cmd and change readonly and it's not write protected I think .
What should I do ? How can I save this sd card ?
two possibilities, first is that being a hardware thing, as micro SDHC have a little notch you can easily notice which matches another notch in the reader and that basically just enables it in read-only mode. That you can't change, just try to use another reader or you could put a piece of silicon or tape on notch, easiest thing is to use another reader.
Second possibility is that being a file permission issue, in which case you can do the following : In terminal, use these commands:
gksudo nautilus
This will launch nautilus in root shell and bypass all permissions. OR:
sudo fdisk -l
This will give you a list of the drives on your system, figure out which drive it is in the list, easiest way is to look for the blocks as this is the space. It will probably be /dev/sdb or /dev/sdc, then
sudo chown -hR <your username> <the SDHC drive, /dev/sdb for example>
this will change ownership of the drive to you. OR:
sudo chmod -R 777 <the SDHC drive, /dev/sdb for example>
Though if you just execute the first command sudo nautilus it will save you all this trouble, but you'll have to do it every time you use the SDHC.
If all of this doesn't work, use this command :
sudo mount --options remount,rw
If you have a Linux computer with an SD/MMC card reader, try running
sudo sdtool /dev/mmcblk0 unlock
Note that you need an MCC device (not a USB mass storage device) for this to work.
sdtool can be found here.
I have been searching in google since one day and I have not found any information of how to resize the webbrowser window (for example, half of the screen) just starting the raspberry pi.
At the moment I achieved starting the webbrowser in kiosk with this code:
In /etc/xdg/lxsession/LXDE-pi/autostart
#xset s off
#xset -dpms
#xset s noblank
#epiphany-browser http://www.google.de
Any idea of how can give/configure a given size to the browser?
I solved by my own.
Just creating a script and using wmctrl in the script.
When starting the PC it run automatically this script.
#!/bin/bash
epiphany http://www.google.de &
sleep 15s
epiphany --new-window www.wikipedia.com &
sleep 15s
SOURCE=/usr/bin
echo "$SOURCE"
$SOURCE/wmctrl -r wikipedia -e 0,0,0,800,1080
$SOURCE/wmctrl -r Google -e 0,800,0,1120,1080
I'm trying to send commands to an STM32F4 microcontroller board via terminal in Linux.
I've tried the following commands:
~$: stty -F /dev/ttyACM0 raw
~$: echo -e -n "\xAA\0xAB\0x10\0x00\0x00\0x00\0x00\0x00\0x01\0x00\0x00\0x00\0x00\0x00\0x00\0x00" > dev/ttyACM0 (this command should tell the stm32 to start recording)
And there is no error, but my STM32F4 board isn't giving me any response back.
Am I doing something wrong? Is there a better way to do this?
I'm currently playing with my brand-new raspberry with adafruit's touch-tft and raspberry Cam.
I noticed, if I run raspivid -p, it displays the preview in a frame on top of the bash.
How can I create an application (java, python, c++(preferred)) to display a GUI without having to startx?
I'd love to use adafruit's touch-tft for a project, but startx needs a lot of resources. Of course it would be cool to have the touch-functionality too.
Edit:
Maybe I expressed myself a little bit confusing: I would like to create an application that doesn't need startx but has some kind of GUI.
The answers below aren't 100% ready to go but they pointed me to the right direction. Since I saw many similar questions I will try to give a step-by-step solution:
Setup your raspberry with adafruit's TFT: https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/overview
(you don't have to replace the TFT with HDMI as standart display)
be sure FRAMEBUFFER=/dev/fb1 startx is running correctly on the TFT screen, I have my TV plugged in the HDMI port, this way I can use the bash on the TV screen and run x on the TFT
Follow this tutorial to create your first pygame: http://www.pygame-doku.laymaxx.de/tut/intro/intro.html
(you can just copy&paste, wget ball.gif)
Insert this 2 lines at the beggining: (github.com/notro/fbtft/wiki/Pygame)
import os
os.environ["SDL_FBDEV"] = "/dev/fb1"
If you want to test the touch-screen to, you can change Line 15:
From:
if event.type == pygame.QUIT: sys.exit()
To:
if event.type == pygame.MOUSEBUTTONDOWN: sys.exit()
This will exit the application if you touch the screen
Save file e.g. pygame1.py and execute with $python pygame1.py
You should now see a bouncing ball on your TFT while the HDMI output still displays the BASH on your TV (but it isn't active of course) touching the screen will exit the game if you completed step 6
Why I'm doing this? This way you can display a simple GUI with e.g. buttons to do some action, like turn your lights on/off if you use your RPI for home-control.
You can use for example pygame library! check this tutorial http://archive.furtherfield.org/rp-resources/RP-workshop-handout.pdf pg. 17
Below, you will find a detailed description of how to be a minimal window manager to start a graphics program of your choice.
-Install Required Packages:
apt-get update
apt-get install xorg - no-install-recommends gdm3 matchbox-window-manager Iceweasel rsync-y
-The system in question, select Add a new user interface gdm3. The terminal is the default name will be used.
adduser kiosk
-Create-Xsession. This script will be executed when the user logs on.
xset s off
xset -dpms
matchbox-window-manager &
while true; do
rsync -qr --delete --exclude='.Xauthority’ /opt/kiosk/ $HOME/
firefox http://www.google.com (Replace your application!!!)
done
Save Ctrl + O; Exit: Ctrl + X
chmod a + x. xsession
cp / opt / kiosk / .xsession / home / kiosk
Set Auto-Login. Kiosk user will enter automatically after boot.
nano / etc/gdm3/daemon.conf
[Daemon]
AutomaticLoginEnable = true
AutomaticLogin = kiosk
We have chosen to configure, program, if necessary
-Screen calibration when not loaded up the whole screen:
/ Boot / config.txt file, clear the comment:
disable_overscan = 1
I hope I helped
Check out Urwid, a text-based ui that can run in a terminal, or, I assume, on a Raspberry Pi started up without startx.
In short you can't, applications like gedit are built atop of a desktop environment (e.g. Gnome, Kde).
I used QEMU to bring CentOS.img (downloaded some where). I find the boot screen of CentOS.img took over the console session of the current terminal and I could see CentOS booting up process and prompts me to the login screen of the guestVM CentOS. This is really helpful for me as I ran QEMU instance from remote console machine.
Now, I created a new RHEL.img using iso and when I try to boot it; I was not able to see anything in the screen other then some symbol of (Y) :(
$>/usr/libexec/qemu-kvm -hda ./RHEL.img -bios bios.bin -nographic -net nic,model=e1000,macaddr=00:AD:BE:EF:4F:BD -net tap,script=./qemu-ifup -m 1024 -smp 2
...Y
on investigation, I find we can do it by redirecting RHEL boot to console using
# virt-edit RHEL_VM /boot/grub/grub.conf
...
title rhel (2.6.38.6-26.rc1.fc15.x86_64)
root (hd0,0)
kernel /vmlinuz ro [...] console=ttyS0
...
but nothing worked out. I am trying to bring the rhel VM session to the same console where I invoked qemu-kvm from remote terminal. Thanks in advance.
NOTE: I don't have GUI enabled on the physical host machine.
You could try adding a serial port and sending output to that. Although you do have to be able to boot it at least once to do these steps...
You might get lucky if you just add a serial port to the qemu command line and then telnet to that; hoping linux detects this and sends output there
edit /etc/init/ttyS0.conf and add
respawn
console none
start on (local-filesystems)
stop on [!12345]
script
exec start ttyS0
end script
then
ln -s /etc/init/ttyS0.conf /etc/rc2.d/S99ttyS0.conf
ln -s /etc/init/ttyS0.conf /etc/rc0.d/S99ttyS0.conf
ln -s /etc/init/ttyS0.conf /etc/rc6.d/S99ttyS0.conf
then do this to enable grub
Edit /etc/default/grub
1. Edit the GRUB_CMDLINE_DEFAULT="" line to start the console on /dev/ttyS0
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,38400n8"
2. Add a serial console section
# Serial console
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --speed=38400 --unit=0 --word=8 --parity=no --stop=1"
3. Rebuild the grub.cfg file
sudo sh
grub-mkconfig > /boot/grub/grub.cfg