|
Although it does say this: A communications resource is a physical or logical device that provides a single bidirectional, asynchronous data stream. Serial ports, parallel ports, fax machines, and modems are examples of communications resources. For each communications resource, there is a service provider, consisting of a library or driver, that enables applications to access the resource.
I do not see anything that is directly related to lpt ports. There is stuff there for Modems and COMM though...
John
|
|
|
|
|
Create a handle to LPT ports[^]. That's all there is. I've tried for years to find more from MS, but they don't want us to know. I assume once you get a handle that some of the other functions work on parallel ports, but it will take some experimenting to make them work. You could try using MSComm32 from VB; it is well documented and usable. If anyone figures it out, this would make an excellent article for CP.
Heard in Bullhead City - "You haven't lost your girl - you've just lost your turn..." [sigh] So true...
|
|
|
|
|
Mostly like reading and writing a file: (EXAMPLE - your mileage may vary...)
void CSerialPort::initPort(int comNumber, int baudRate)
{
closePort();
m_ComNumber = comNumber;
m_BaudRate = baudRate;
CString comStr;
comStr.Format(_T("%s%d"), _T("COM"), comNumber);
m_ComHandle = CreateFile(comStr,
GENERIC_READ | GENERIC_WRITE,
0, 0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
DCB dcb;
GetCommState(m_ComHandle, &dcb);
dcb.BaudRate = m_BaudRate;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
SetCommState(m_ComHandle, &dcb);
COMMTIMEOUTS timeouts;
timeouts.ReadIntervalTimeout = MAXDWORD;
timeouts.ReadTotalTimeoutMultiplier = 0;
timeouts.ReadTotalTimeoutConstant = 0;
timeouts.WriteTotalTimeoutMultiplier = 0;
timeouts.WriteTotalTimeoutConstant = 0;
SetCommTimeouts(m_ComHandle, &timeouts);
EscapeCommFunction(m_ComHandle, SETRTS);
EscapeCommFunction(m_ComHandle, SETDTR);
}
bool CSerialPort::readByteFromChannel(char* inByte)
{
DWORD numRead;
BOOL ret = true;
ret = ReadFile(m_ComHandle, inByte, 1, &numRead, 0);
return ( (ret) && (numRead == 1) );
}
void CSerialPort::sendPacket(char* pktBuffer, int len)
{
DWORD numWritten;
WriteFile(m_ComHandle, pktBuffer, len, &numWritten, 0);
if (numWritten != (DWORD)len)
// do comm error handling here
}
|
|
|
|
|
This is for a serial port not parallel...
John
|
|
|
|
|
sorry...embarrassed...
Must have serial port WAY too embedded in my brain right now to
read "parallel" as "serial"...
Apologies if it created confusion for the original poster.
John
|
|
|
|
|
I have a file with stuff like:
11 45 67
12 17 11 60
15 17 89
17 5
etc where the line ends with a carriage return but theres no set spacing between the integers. The only thing I know is that each integer is two digits, but theres no restriction on how many per line and spacing. I want to read each integer into a variable (that I'll pushback onto a vector). I saw fread, and fgets but they dont seem to look like they will do.
thanks,
ns
|
|
|
|
|
ns wrote:
I saw fread, and fgets but they dont seem to look like they will do.
One option is to read each line in, using fgets, or the stl's stream such as istrstream. Then use _tcstok() to separate the space delimited integer strings. After that you can then use _ttoi to convert each string to an integer value.
I Dream of Absolute Zero
|
|
|
|
|
Hey,
This is how you can do it in C++:
#include <fstream>
#include <vector>
int main() {
std::ifstream fin("test.txt");
fin >> std::skipws;
std::vector<int> test;
int j;
while (fin >> j)
test.push_back(j);
return 0;
}
Hope that helps you.
--
Henrik Stuart (http://www.unprompted.com/hstuart/)
|
|
|
|
|
Good Soultion, Thanks. I learn something new every day just reading these posts...
John
|
|
|
|
|
Try this using fscanf()
FILE *fopen( "Yourfile" );<br />
int nIn = 0;<br />
while ( fscanf( fp, "%d ", &nIn ) == 1 )<br />
{<br />
}<br />
fclose( fp );<br />
Note the space following the %d.
Personally I prefer to read text files line-by-line using fgets(), and then parse each line but as long as there are no bogies in the data, the above should work fine.
|
|
|
|
|
I appreciate the swift responses. They are very helpful. Many thanks to all of you for helping,
ns
|
|
|
|
|
Hey, how are you? And happy birthday, my dear!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
And to you too! Getting a little old there eh? Not me....I'm just a youngster....haha!
My computer died on me....so only have one machine today...aaargh. I'm taking a course on data structures (at the local univ but online). Its fun! In the middle of a project for solving mazes with depth first search. My son graduated from bootcamp last week....we had 15 degrees in Chicago! Fun city though...
Gotta call polywell now for my athlon......yaaaargh! Later!
|
|
|
|
|
ns wrote:
Not me....I'm just a youngster
'Tis the only way to be!
ns wrote:
My son graduated from bootcamp last week
Congratulations!
ns wrote:
solving mazes with depth first search.
Brings back fond memories! Check out Data Structures + Algorithms = Programs (by Nicklaus Wirth). Dated, but still a good book. Wirth is the co-inventor if Pascal. I met him in Zurich in 1987 at the ETH. Really nice guy!
ns wrote:
we had 15 degrees in Chicago
Toasty warm compared to what Boston's been getting!
Have a swell year!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Not virtual memory but physical memory does a machine have. Does anyone know the name of an API that will return the amount of physical memory?
thanks
|
|
|
|
|
check GlobalMemoryStatus , GlobalMemoryStatusEx
|
|
|
|
|
See this thread.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
|
hi there,
i need to process some stuff every time my cwnd obj gets scrolled. the problem is that onvscroll is not called if one scrolls with the wheel.
can somebody help me please?
Я люблю русский языкь!
|
|
|
|
|
Try processing the WM_MOUSEWHEEL message.
onwards and upwards...
|
|
|
|
|
Hello, I'm going to code an own small kernel, but I have a problem concerning the compiler to use.
I want to use Microsoft compilers, but there is the problem, that these compiler always what to create PE files, and I need a binary file with a base address of 0x00000000.
The GCC compiler supports this by using the command "-ffreestanding".
Is there any equivalent for Microsoft compilers or any other way using Microsoft compilers to do this?
Thank you for your attention.
Alexander M.
Don't try it, just do it!
|
|
|
|
|
You will get PE format only if you are building a win32 application, naturally you dont want win32, you want a .COM type application whose memory model will be TINY. that will not have any far calls and no .exe header,
Tried looking for tiny option in msdn but could not find it.
You can i suppose use the VC IDE and use gcc compiler to do the compilation by using custom build.
hope i helped in some way.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
thanks
Don't try it, just do it!
|
|
|
|
|
i want to get the handle of a clicked window among various opened windows;
when i click any opened window i want to ge the handle of it
Hawk,amr
|
|
|
|
|
WindowFromPoint(...) Gives you the handle of the window that was clicked.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|