Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Saturday, December 08, 2007

Linux Virtual Serial Port

When programming with Serial Ports, is often useful to have 2 Virtual Serial Ports communicating each other for debugging, without the need of a Null Modem serial cable connected to phisical serial ports of the same Pc, or connected to a second Pc.
What you need is VSPD!
Download the RPM or tar.gz packet from http://www.tibbo.com/vspdl.php
Install it following the instructions, then you should find the vspd.conf file in /usr/local/vspd/etc/ folder.
Open it and edit as follow (modify the IP 192.168.1.3 with your IP address):

<!-- **** VIRTUAL SERIAL PORT DRIVER FOR LINUX (VSPDL) CONFIGURATION FILE **** -->
<!-- Copyright (C) 2003-2004, Tibbo Technology Inc. -->
<vspdconfig>

<root dir="/usr/local/vspd"/>

<devprefix value="/dev/vspd"/>

<bind host="192.168.1.3"/>

<timeout exec="10000" priority="10"/>

<log type="file" level="EMR" path="var/vspd.log"/>
<log type="file" level="ALR" path="var/vspd.log"/>
<log type="file" level="CRT" path="var/vspd.log"/>
<log type="file" level="ERR" path="var/vspd.log"/>
<log type="file" level="WRN" path="var/vspd.log"/>
<log type="file" level="NTC" path="var/vspd.log"/>
<log type="file" level="INF" path="var/vspd.log"/>
<log type="file" level="DBG" path="var/vspd.log"/>

<vsp num="0">

<bind host="" port="3500"/>

<connection rmode="server/client" proto="tcp" conmode="ondata" timeout="5" onthefly="outofband"/>

<destination ip="192.168.1.3" port="3501" cport="65535"/>

<packets maxlen="255" maxdelay="0" starton="any"/>

<log type="file" level="EMR" path="var/dev.0.log"/>
<log type="file" level="ALR" path="var/dev.0.log"/>
<log type="file" level="CRT" path="var/dev.0.log"/>
<log type="file" level="ERR" path="var/dev.0.log"/>
<log type="file" level="WRN" path="var/dev.0.log"/>
<log type="file" level="NTC" path="var/dev.0.log"/>
<log type="file" level="INF" path="var/dev.0.log"/>

</vsp>

<vsp num="1">

<bind host="192.168.1.3" port="3501"/>

<connection rmode="server/client" proto="tcp" conmode="ondata" timeout="5" onthefly="outofband"/>

<destination ip="192.168.1.3" port="3500" cport="65535"/>

<packets maxlen="255" maxdelay="0" starton="any"/>


<log type="file" level="EMR" path="var/dev.1.log"/>
<log type="file" level="ALR" path="var/dev.1.log"/>
<log type="file" level="CRT" path="var/dev.1.log"/>
<log type="file" level="ERR" path="var/dev.1.log"/>
<log type="file" level="WRN" path="var/dev.1.log"/>
<log type="file" level="NTC" path="var/dev.1.log"/>
<log type="file" level="INF" path="var/dev.1.log"/>

</vsp>

</vspdconfig>

Now you can start the service with
#/etc/rc.d/init.d/vspd start
or, if the service was already running:
#/etc/rc.d/init.d/vspd reloadconf

To test the communication I used minicom on two different consoles, setting first to the port /dev/vsps0, and second to /dev/vsps1

Sunday, November 25, 2007

MKV to AVI under Linux

You need:
MKVtoolnix


1. MKV is a container, to see what the file contains:
$ mkvinfo movie.mkv
Ex:
+ EBML head
|+ Doc type: matroska
|+ Doc type version: 1
|+ Doc type read version: 1
+ Segment, size 736993124
|+ Seek head (subentries will be skipped)
|+ EbmlVoid (size: 4027)
|+ Segment information
| + Timecode scale: 1000000
| + Muxing application: libebml v0.7.3 + libmatroska v0.7.4
| + Writing application: mkvmerge v1.0 ('Soul Food To Go') built on Nov 17 2004 15:06:35
| + Duration: 3682.987s (01:01:22.987000000)
| + Date: Wed Dec 8 15:42:45 2004 UTC
| + Title: Il Coraggioso - The Brave
| + Segment UID: 0x84 0xad 0xc1 0x0b 0x8e 0x9b 0x06 0x84 0xef 0x2a 0xf9 0xa6 0xf4 0x94 0x07 0x5d
| + Next segment UID: 0xeb 0x46 0x75 0xb4 0x7a 0x71 0xc2 0x7f 0xc7 0x36 0x44 0x06 0x9b 0xe4 0x90 0x76
|+ Segment tracks
| + A track
| + Track number: 1
| + Track UID: 38700354
| + Track type: video
| + Default flag: 1
| + Lacing flag: 0
| + MinCache: 1
| + Timecode scale: 1.000000
| + Codec ID: V_MS/VFW/FOURCC
| + CodecPrivate, length 40 (FourCC: XVID, 0x44495658)
| + Default duration: 40.000ms (25.000 fps for a video track)
| + Language: und
| + Name: Il Coraggioso - the Brave
| + Video track
| + Pixel width: 608
| + Pixel height: 336
| + Display width: 608
| + Display height: 336
| + A track
| + Track number: 2
| + Track UID: 3348909422
| + Track type: audio
| + Default flag: 1
| + Lacing flag: 1
| + MinCache: 0
| + Timecode scale: 1.000000
| + Codec ID: A_AAC/MPEG2/LC/SBR
| + Default duration: 42.667ms (23.438 fps for a video track)
| + Language: ita
| + Name: Ita aac 5.1
| + Audio track
| + Sampling frequency: 24000.000000
| + Channels: 6
| + Output sampling frequency: 48000.000000
|+ EbmlVoid (size: 1024)
|+ Cluster

2. select the numbers of the trucks you want to extract and type:
$ mkvextract tracks "/mnt/common/Film/movie.mkv" 1:/mnt/common/Film/movie.avi 2:/mnt/common/Film/movie.aac

3. If the audio file has the aac format you need also:
faad
lame

4. To convert the file audio in mp3 format:
$ faad -d /mnt/common/Film/movie.aac
$ lame /mnt/common/Film/movie.wav


5. Let's put all toghether:
$ mencoder -audiofile movie.wav.mp3 -oac mp3lame -ovc copy movie.avi -o movie_complete.avi

Monday, October 08, 2007

Qt4 Tux Example

main.cpp

#include "console883.h"

#include
#include


int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QString fn = "tux.png";

if ( ! QFile::exists( fn ) )
exit( 1 );

Console883 w(0,Qt::FramelessWindowHint);
QPixmap pixmap(fn);

QPalette palette;
palette.setBrush(w.backgroundRole(), QBrush(pixmap));
w.setPalette(palette);
w.setFixedSize( pixmap.size() );
w.setMask(pixmap.mask());
w.show();

a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}


--------------------------------------------------------------------------------------------------------------
console883.h

#ifndef CONSOLE883_H
#define CONSOLE883_H

#include
#include
#include "ui_console883.h"

class Console883 : public QWidget
{
Q_OBJECT

public:
Console883(QWidget *parent = 0, Qt::WFlags f = 0);
~Console883();
void show();

protected:
void mousePressEvent( QMouseEvent *);
void mouseMoveEvent( QMouseEvent *);

private:
Ui::Console883Class ui;

QPoint clickPos;
};

#endif // CONSOLE883_H



----------------------------------------------------------------------------------------------------------------
console883.cpp

#include "console883.h"

Console883::Console883(QWidget *parent, Qt::WFlags f)
: QWidget(parent, f)

{
//ui.setupUi(this);
}

Console883::~Console883()
{

}

void Console883::show()
{
ui.setupUi(this);
QWidget::show();
}

void Console883::mousePressEvent( QMouseEvent *e )
{
clickPos = e->pos();
}

void Console883::mouseMoveEvent( QMouseEvent *e )
{
move( e->globalPos() - clickPos );

}





Thursday, June 21, 2007

Netcat & Busybox

Configurazione di netcat su busybox per fare reverse telnet su una console remota e avere accesso ad un database sqlite. Questo permette di avere accesso al database di una macchina di cui non si conosce l'ip e che è sotto firewall.

Utilizzata Busybox 1.2.1. Entrare in "Networking Utilities"e attivare "nc" e "gaping security hole" (altrimenti l'opzione -e non viene attivata).

Sul server da cui si vuole accedere alla console digitare:
#nc -vv -l -p 80
Sulla console creare il comando eseguibile opendb.sh:
#!/bin/sh
sqlite /usr/secure/database/manager994.db

quindi eseguire il comando
#nc -e opendb.sh xxx.xxx.xxx.xxx 80
dove xxx.xxx.xxx.xxx è l'ip del server


Saturday, February 18, 2006

T610 bluetooth connection under Linux

Compenents:
  1. Acer laptop
  2. Bluetooth usb pen
  3. Sony-Ericsson T610 cell-phone
  4. Mandriva 2006
I followed the instructions in http://www.teaparty.net/technotes/blue-gprs.html
Commands:
#hcitool scan
Scanning ...
00:0E:07:63:E6:B3 T610 David
#rfcomm bind 0 00:0E:07:63:E6:B3 1
#minicom
Serial Port Setup
Serial Device: /dev/rfcomm0
Bps/Par/Bits: 8N1
Hardware Flow Control: OFF
Software Flow Control: ON
Save Setup as dfl
Exit
#minicom
AT
OK