1. Setup two machines: target machine and debugging machie
2. Download windbg at the debugging machine
http://msdn.microsoft.com/en-us/windows/hardware/gg463009
for window XP you need to download the Windows 7 version
3. Change the boot.ini file in taget machine to recognize com1 serial port.
4. Boot target machine into debugging mode ( press F8 when booting)
5. Start windbg at the debugging machine, and choose the correct device.
e.g. Serial port to USB
6. Set the the correct symbol table path.
e.g. srv*c\symbols*http://msdl.microsoft.com/download/symbols
7. run dt _eprocess
How to change boot.ini
http://www.etdot.com/2008/04/16/windbg-and-vmware/
http://support.microsoft.com/kb/289022
You also can get more information from: Windows Internals book 5 Edition
Another book: Advanced Windows Debugging
Showing posts with label Serial Port. Show all posts
Showing posts with label Serial Port. Show all posts
Monday, April 9, 2012
Tuesday, February 28, 2012
Serial port to USB on Mac
This link provides the detailed the solution.
http://www.planet-rcs.de/article/mac_serial_port/
Note:
1. make sure you are using PL-2303 cable
2. In addition to the software mentioned in the link, you could use minicom. It has the same function in Linux.
http://www.planet-rcs.de/article/mac_serial_port/
Note:
1. make sure you are using PL-2303 cable
2. In addition to the software mentioned in the link, you could use minicom. It has the same function in Linux.
Wednesday, March 23, 2011
User MATLAB to setup the serial port
s=serial('COM8');
set(s,'BaudRate',9600);
fopen(s);
http://newsgroups.derkeiler.com/Archive/Comp/comp.soft-sys.matlab/2008-10/msg05119.html
set(s,'BaudRate',9600);
fopen(s);
http://newsgroups.derkeiler.com/Archive/Comp/comp.soft-sys.matlab/2008-10/msg05119.html
Tuesday, March 22, 2011
Serial Port Programming on Windows
Here is a sample code of serial port programming on Windows:
it compile and run at Dev C++, but you need to change CreateFile to CreateFileA on VC++ 2010 express
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <commdlg.h>
#include <windef.h>
int nread,nwrite;
int main()
{
HANDLE hSerial;
COMMTIMEOUTS timeouts;
COMMCONFIG dcbSerialParams;
char *words, *buffRead, *buffWrite;
DWORD dwBytesWritten, dwBytesRead;
hSerial = CreateFile("COM1",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if ( hSerial == INVALID_HANDLE_VALUE)
{
if (GetLastError() == ERROR_FILE_NOT_FOUND)
{
printf(" serial port does not exist \n");
}
printf(" some other error occured. Inform user.\n");
}
//DCB dcbSerialParams ;
//GetCommState( hSerial, &dcbSerialParams.dcb);
if (!GetCommState(hSerial, &dcbSerialParams.dcb))
{
printf("error getting state \n");
}
dcbSerialParams.dcb.DCBlength = sizeof(dcbSerialParams.dcb);
dcbSerialParams.dcb.BaudRate = CBR_38400;
dcbSerialParams.dcb.ByteSize = 8;
dcbSerialParams.dcb.StopBits = TWOSTOPBITS;
dcbSerialParams.dcb.Parity = NOPARITY;
dcbSerialParams.dcb.fBinary = TRUE;
dcbSerialParams.dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcbSerialParams.dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcbSerialParams.dcb.fOutxCtsFlow = FALSE;
dcbSerialParams.dcb.fOutxDsrFlow = FALSE;
dcbSerialParams.dcb.fDsrSensitivity= FALSE;
dcbSerialParams.dcb.fAbortOnError = TRUE;
if (!SetCommState(hSerial, &dcbSerialParams.dcb))
{
printf(" error setting serial port state \n");
}
GetCommTimeouts(hSerial,&timeouts);
//COMMTIMEOUTS timeouts = {0};
timeouts.ReadIntervalTimeout = 50;
timeouts.ReadTotalTimeoutConstant = 50;
timeouts.ReadTotalTimeoutMultiplier = 10;
timeouts.WriteTotalTimeoutConstant = 50;
timeouts.WriteTotalTimeoutMultiplier= 10;
if(!SetCommTimeouts(hSerial, &timeouts))
{
printf("error setting port state \n");
}
//****************Write Operation*********************//
words = "This is a string to be written to serial port COM1";
nwrite = strlen(words);
buffWrite = words;
dwBytesWritten = 0;
if (!WriteFile(hSerial, buffWrite, nwrite, &dwBytesWritten, NULL))
{
printf("error writing to output buffer \n");
}
//printf("Data written to write buffer is \n %s \n",buffWrite);
//***************Read Operation******************//
/*
buffRead = 0;
dwBytesRead = 0;
nread = strlen(words);
if (!ReadFile(hSerial, buffRead, nread, &dwBytesRead, NULL))
{
printf("error reading from input buffer \n");
}
printf("Data read from read buffer is \n %s \n",buffRead);
*/
CloseHandle(hSerial);
system("pause");
return 1;
}
it compile and run at Dev C++, but you need to change CreateFile to CreateFileA on VC++ 2010 express
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <commdlg.h>
#include <windef.h>
int nread,nwrite;
int main()
{
HANDLE hSerial;
COMMTIMEOUTS timeouts;
COMMCONFIG dcbSerialParams;
char *words, *buffRead, *buffWrite;
DWORD dwBytesWritten, dwBytesRead;
hSerial = CreateFile("COM1",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if ( hSerial == INVALID_HANDLE_VALUE)
{
if (GetLastError() == ERROR_FILE_NOT_FOUND)
{
printf(" serial port does not exist \n");
}
printf(" some other error occured. Inform user.\n");
}
//DCB dcbSerialParams ;
//GetCommState( hSerial, &dcbSerialParams.dcb);
if (!GetCommState(hSerial, &dcbSerialParams.dcb))
{
printf("error getting state \n");
}
dcbSerialParams.dcb.DCBlength = sizeof(dcbSerialParams.dcb);
dcbSerialParams.dcb.BaudRate = CBR_38400;
dcbSerialParams.dcb.ByteSize = 8;
dcbSerialParams.dcb.StopBits = TWOSTOPBITS;
dcbSerialParams.dcb.Parity = NOPARITY;
dcbSerialParams.dcb.fBinary = TRUE;
dcbSerialParams.dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcbSerialParams.dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcbSerialParams.dcb.fOutxCtsFlow = FALSE;
dcbSerialParams.dcb.fOutxDsrFlow = FALSE;
dcbSerialParams.dcb.fDsrSensitivity= FALSE;
dcbSerialParams.dcb.fAbortOnError = TRUE;
if (!SetCommState(hSerial, &dcbSerialParams.dcb))
{
printf(" error setting serial port state \n");
}
GetCommTimeouts(hSerial,&timeouts);
//COMMTIMEOUTS timeouts = {0};
timeouts.ReadIntervalTimeout = 50;
timeouts.ReadTotalTimeoutConstant = 50;
timeouts.ReadTotalTimeoutMultiplier = 10;
timeouts.WriteTotalTimeoutConstant = 50;
timeouts.WriteTotalTimeoutMultiplier= 10;
if(!SetCommTimeouts(hSerial, &timeouts))
{
printf("error setting port state \n");
}
//****************Write Operation*********************//
words = "This is a string to be written to serial port COM1";
nwrite = strlen(words);
buffWrite = words;
dwBytesWritten = 0;
if (!WriteFile(hSerial, buffWrite, nwrite, &dwBytesWritten, NULL))
{
printf("error writing to output buffer \n");
}
//printf("Data written to write buffer is \n %s \n",buffWrite);
//***************Read Operation******************//
/*
buffRead = 0;
dwBytesRead = 0;
nread = strlen(words);
if (!ReadFile(hSerial, buffRead, nread, &dwBytesRead, NULL))
{
printf("error reading from input buffer \n");
}
printf("Data read from read buffer is \n %s \n",buffRead);
*/
CloseHandle(hSerial);
system("pause");
return 1;
}
CreateFile vs CreateFileW , CreateFileA
This is the simple explaination:
CreateFileW (Unicode) and CreateFileA (ANSI)
both of them defined by CreateFile
If you want to understand CreateFile, go to msdn page(man page of win API):
http://msdn.microsoft.com/en-us/library/aa363858%28v=vs.85%29.aspx
Here is the link talk about the difference:
http://www.osronline.com/showThread.cfm?link=20658
Note: if you compile following code on Visual studio 2010 Express may have errors, just change CreateFile() to CreateFileA()
CreateFileW (Unicode) and CreateFileA (ANSI)
both of them defined by CreateFile
If you want to understand CreateFile, go to msdn page(man page of win API):
http://msdn.microsoft.com/en-us/library/aa363858%28v=vs.85%29.aspx
Here is the link talk about the difference:
http://www.osronline.com/showThread.cfm?link=20658
Note: if you compile following code on Visual studio 2010 Express may have errors, just change CreateFile() to CreateFileA()
hSerial = CreateFile("COM1",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
Wednesday, December 1, 2010
serial port
Get which serial port device is active
Get the bard rate of serial port device sttyS0
Put some data in serial port
receive data from serial port of other machine (if use USB to receive)
usually, you will see binary data from terminal. You could use minicom to receive data
Install minicom
Start minicom and save output
If you didn't set up the serial port, you need set up first, run
Setup the device and baud rate. you could run following cmd to see the device
I assume you use USB, the you could see /dev/ttyUSB0. set the device to /dev/USB0 in the minicom. and You need to set the bard rate. Usually, it is 9600, some times it would be 115200(like coreboot set the serial port rate)
Finally, you will see data from terminal, you could also save the output.
$ dmesg | grep tty
Get the bard rate of serial port device sttyS0
$stty -F /dev/sttyS0
Put some data in serial port
$echo hello > /dev/sttyS0
receive data from serial port of other machine (if use USB to receive)
$cat /dev/ttyUSB0
usually, you will see binary data from terminal. You could use minicom to receive data
Install minicom
$sudo apt-get install minicom
Start minicom and save output
$minicom -C output
If you didn't set up the serial port, you need set up first, run
$minicom -s
Setup the device and baud rate. you could run following cmd to see the device
$ls /dev/tty*
I assume you use USB, the you could see /dev/ttyUSB0. set the device to /dev/USB0 in the minicom. and You need to set the bard rate. Usually, it is 9600, some times it would be 115200(like coreboot set the serial port rate)
Finally, you will see data from terminal, you could also save the output.
Subscribe to:
Posts (Atom)