Sending characters to Olivetti PR2 RS232 dotmatrix printer

Windows specific forum
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 543
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Sending characters to Olivetti PR2 RS232 dotmatrix printer

Post by bbanelli »

Greetings,

I have a printer that works in Olivetti PR2 emulation. It is connected to COM4 port on Windows.

Following commands work from Windows CLI.

Code: Select all

set /p x="some text" <nul >\\.\COM4

Code: Select all

type somefile.txt >\\.\COM4
Printing works via Print dialogue in PureBasic as well, however...

Is there a possibility to "emulate" commands above, since printer than works in native mode and not (very slow and nonflexible) graphics mode when I print it via Print library in PB? Can I use StartPrinting() function with some "native" mode for such dot-matrix printers?

BTW, i CANNOT access COM4 port from PB's commands...

Thank you in advance,

Bruno

Edit: I tried something like this, but compiler crushes...

Code: Select all

txt.s = "0123456789"
hndl.i = CreateFile_("\\.\COM4", #GENERIC_ALL, #FILE_SHARE_READ, #Null, #OPEN_EXISTING, #Null, #Null)
WriteFile_(hndl, @txt, Len(txt), #Null, #Null)
CloseHandle_(hndl)

Code: Select all

Problem signature:
  Problem Event Name:	APPCRASH
  Application Name:	PureBasic_Compilation0.exe
  Application Version:	0.0.0.0
  Application Timestamp:	5ad88724
  Fault Module Name:	KERNELBASE.dll
  Fault Module Version:	6.1.7601.23915
  Fault Module Timestamp:	59b94f2a
  Exception Code:	c0000005
  Exception Offset:	0000000000001b54
  OS Version:	6.1.7601.2.1.0.256.1
  Locale ID:	1050
  Additional Information 1:	6b14
  Additional Information 2:	6b148cf49d296fa0cbd4faef530b5e86
  Additional Information 3:	500e
  Additional Information 4:	500eec2a859faeef979f97032c85988a

Read our privacy statement online:
  http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
  C:\Windows\system32\en-US\erofflps.txt
WriteFile_ part seems to be the one causing the error.

Solution

http://www.purebasic.fr/german/viewtopic.php?f=3&t=1152
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/