Tuesday, October 16, 2007

Visual Basic 2005 FileDialog Example

Below is a simple example of a Save As dialog could look like.

' Save Dialog
With SaveFileDialog1
.DefaultExt = "exp" ' Default extension if user doesn't add one
.Filter = "Exp file (*.exp)|*.exp|Any (*.*)|*.*" ' Using *.exp as filter OR show all
.FilterIndex = 0 ' Use *.exp as default
.InitialDirectory = "C:\"
.Title = "Save TwinCat *.Exp file to .."
If .ShowDialog() = Windows.Forms.DialogResult.Cancel Then Exit Sub ' User pressed Cancel so exit

End With
' Append some text to this file
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, "Test", True)

Wednesday, September 05, 2007

Using winsock to send data using UDP protocol

I learned a lesson today, don't send big chunk of data with UDP. It will not be received properly.
I had to limit the size of data to 1471 bytes. Why, its due to MTU size, the UDP package will be defragmented.

Ethernet has a limit of about 1500 bytes per ethernet packet. This is called the MTU, Maximum Transmission Unit. I guess some space is needed for the UDP header, that why the biggest size possible to send was 1471 bytes of data.

The problem gets more complex, because an IP packet being sent across the internet may cross several types of hardware. That means an IP packet may be fragmented as it travels from source to destination.
The minimum hardware packet size on the path from source to destination is called the “path MTU”. Any packet larger than this will be fragmented.
IP packet fragmentation just means that the original IP packet will be broken up into two or more IP packets.
In TCP, these will just be re-assembled as normal.
UDP can do something similar. A big UDP packet can be fragmented into several IP packets. UDP makes no big attempts to reassemble, though. If one fragmented IP packet is dropped, the whole UDP packet is dropped.
Source: http://www.movesinstitute.org/~mcgredo/mv3500/lectures/Lecture13.ppt

Friday, August 24, 2007

TV card in Linux

I finally get my asus TV card to work under Kubuntu 7.04.
The video worked but there wasn't any sound.
Googling I found following at:
http://osdir.com/ml/video.tvtime.devel/2006-11/msg00017.html
You may try to use:
1) modprobe saa7134-alsa
2) sox -r 32000 -w -t ossdsp /dev/dsp1 -t ossdsp /dev/dsp
where /dev/dsp1 is your TV card sound device and /dev/dsp
your main soundcard.
Let sox run an open tvtime (or other TV application) from a
different terminal.
I didn't have sox installed so I run: sudo apt-get install sox
The bad thing you have to run
sox -r 32000 -w -t ossdsp /dev/dsp1 -t ossdsp /dev/dsp
every time to get sound.

MySQL to MariaDB

 Here is a good description how to migrate to MariaDb MySQL to MariaDb Example of how to dump data from MySQL port=3307: mysqldump --user=ro...