Форум » [x]Harbour » [?] Datecs Ep-60 (SDK) » Ответить

[?] Datecs Ep-60 (SDK)

Dima: Есть SDK к принтеру http://datecs.bg/get_file.php?soft_id=49FD25D571CAD192F17BFCB200B0034A Возможно ли в Xharbour его заюзать ? Если возможно то с чего начинается родина ? Если можно то на примере вывода простого текста на печать. PS Ни когда еще не юзал какие либо SDK

Ответов - 42, стр: 1 2 3 All

Pasha: Надо написать модуль с wrapper-функциями: [pre]#include "hbapi.h" #include "printing.h" HB_FUNC( DTX_PRNOPEN ) { hb_retnl( PrnOpen( hb_parnl(1), hb_parnl(2), hb_parl(3)) ); } HB_FUNC( DTX_PRNCLOSE ) { hb_retnl( PrnClose() ); } HB_FUNC( DTX_PRNTEXT ) { hb_retnl( PrnText(hb_parc(1)) ); } HB_FUNC( DTX_PRNBARCODE ) { hb_retnl( PrnBarcode(hb_parnl(1), hb_parc(2), hb_parclen(2)) ); }[/pre] и так для каждой функции собирать программу с этим модулем, и с printing.lib

Dima: Pasha Спасибо большое !!!!!!! Буду пробовать.

Dima: Pasha Начал пробовать. Исходник [pre2] Proc main if dtx_propen(4,57600,.t.)==0 dtx_prntext("Блаблабла") dtx_prnclose() endif return #pragma BEGINDUMP #include "hbapi.h" #include "printing.h" HB_FUNC( DTX_PRNOPEN ) { hb_retnl( PrnOpen( hb_parnl(1), hb_parnl(2), hb_parl(3)) ); } HB_FUNC( DTX_PRNCLOSE ) { hb_retnl( PrnClose() ); } HB_FUNC( DTX_PRNTEXT ) { hb_retnl( PrnText(hb_parc(1)) ); } HB_FUNC( DTX_PRNBARCODE ) { hb_retnl( PrnBarcode(hb_parnl(1), hb_parc(2), hb_parclen(2)) ); } #pragma ENDDUMP [/pre2] Во время сборки получаю вот такую лажу , что делать ? [pre2] Building object module for 'obj\TEST.c' using C compiler 'BCC32' as defined in 'c:\x\bin\harbour.cfg'... Exec: BCC32 -c -D__EXPORT__ -Ic:\x\include -d -Lc:\x\lib -oobj\TEST.obj obj\TEST.c Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland obj\TEST.c: Error E2139 printing.h 116: Declaration missing ; Error E2238 printing.h 117: Multiple declaration for 'bool' Error E2344 printing.h 116: Earlier declaration of 'bool' Error E2139 printing.h 117: Declaration missing ; Error E2238 printing.h 118: Multiple declaration for 'bool' Error E2344 printing.h 116: Earlier declaration of 'bool' Error E2139 printing.h 118: Declaration missing ; Error E2238 printing.h 119: Multiple declaration for 'bool' Error E2344 printing.h 116: Earlier declaration of 'bool' Error E2139 printing.h 119: Declaration missing ; Error E2238 printing.h 120: Multiple declaration for 'bool' Error E2344 printing.h 116: Earlier declaration of 'bool' Error E2139 printing.h 120: Declaration missing ; Error E2238 printing.h 121: Multiple declaration for 'bool' Error E2344 printing.h 116: Earlier declaration of 'bool' Error E2139 printing.h 121: Declaration missing ; Error E2238 printing.h 122: Multiple declaration for 'bool' Error E2344 printing.h 116: Earlier declaration of 'bool' Error E2139 printing.h 122: Declaration missing ; Error E2238 printing.h 123: Multiple declaration for 'bool' Error E2344 printing.h 116: Earlier declaration of 'bool' Error E2139 printing.h 123: Declaration missing ; Error E2238 printing.h 124: Multiple declaration for 'bool' Error E2344 printing.h 116: Earlier declaration of 'bool' Error E2139 printing.h 124: Declaration missing ; Error E2228 printing.h 124: Too many error or warning messages *** 26 errors in Compile *** Done. Deleting: "obj\TEST.c" Done. [/pre2] [pre2] typedef struct PRINTER_INFORMATION { char name[23]; int printer; int fwver; int langver; int pagewidth; int maxlogoheight; int maxlogosize; int feedlines; bool irda; // 116 строка Printing.h bool msr; bool msr3track; bool katakana; bool shiftjis; bool fahrenheit; bool bluetooth; bool firmwareupdate; bool korean; bool blackmark; bool barcodereader; bool usba; bool usbb; bool sw1; bool sw2; bool sw3; bool sw4; bool sw5; bool sw6; bool sw7; bool sw8; bool sw9; bool sw10; bool sw11; bool sw12; bool sw13; bool sw14; bool sw15; bool sw16; bool sw17; bool sw18; bool sw19; bool sw20; bool universalreader; }PRINTER_INFORMATION; [/pre2]


Pasha: там используется тип bool, который bcc не знает. Надо перед строкой #include "printing.h" вставить строку typedef unsigned char bool; я думаю, unsigned char это и есть bool. Во всяком случае, в паскалевском модуле это тип Boolean

Dima: Сделал так [pre2] #include "hbapi.h" typedef unsigned char bool; #include "printing.h" HB_FUNC( DTX_PRNOPEN ) { hb_retnl( PrnOpen( hb_parnl(1), hb_parnl(2), hb_parl(3)) ); } HB_FUNC( DTX_PRNCLOSE ) { hb_retnl( PrnClose() ); } HB_FUNC( DTX_PRNTEXT ) { hb_retnl( PrnText(hb_parc(1)) ); } HB_FUNC( DTX_PRNBARCODE ) { hb_retnl( PrnBarcode(hb_parnl(1), hb_parc(2), hb_parclen(2)) ); } #pragma ENDDUMP [/pre2] Теперь получаю следующее Error E2040 printing.h 194: Declaration terminated incorrectly Error E2040 printing.h 210: Declaration terminated incorrectly Error E2040 printing.h 223: Declaration terminated incorrectly Error E2040 printing.h 270: Declaration terminated incorrectly Error E2040 printing.h 279: Declaration terminated incorrectly Error E2040 printing.h 287: Declaration terminated incorrectly Error E2040 printing.h 305: Declaration terminated incorrectly Error E2040 printing.h 318: Declaration terminated incorrectly Error E2040 printing.h 335: Declaration terminated incorrectly Error E2040 printing.h 355: Declaration terminated incorrectly Error E2040 printing.h 368: Declaration terminated incorrectly Error E2040 printing.h 382: Declaration terminated incorrectly Error E2040 printing.h 409: Declaration terminated incorrectly 194 строка extern "C" int __stdcall PrnOpen(int port, int speed, bool hardware);

Pasha: можно по-другому, просто поставить #define bool char

Dima: Pasha пишет: #define bool char Где это прописать ? Если прописывать вместо typedef unsigned char bool; тогда при сборке получаю Error E2040 TEST.PRG 10: Declaration terminated incorrectly

Dima: Dima пишет: Где это прописать ? Разобрался. Думал что закоментарил *typedef unsigned char bool; Но все равно Dima пишет: Error E2040 printing.h 194: Declaration terminated incorrectly Error E2040 printing.h 210: Declaration terminated incorrectly Error E2040 printing.h 223: Declaration terminated incorrectly Error E2040 printing.h 270: Declaration terminated incorrectly Error E2040 printing.h 279: Declaration terminated incorrectly Error E2040 printing.h 287: Declaration terminated incorrectly Error E2040 printing.h 305: Declaration terminated incorrectly Error E2040 printing.h 318: Declaration terminated incorrectly Error E2040 printing.h 335: Declaration terminated incorrectly Error E2040 printing.h 355: Declaration terminated incorrectly Error E2040 printing.h 368: Declaration terminated incorrectly Error E2040 printing.h 382: Declaration terminated incorrectly Error E2040 printing.h 409: Declaration terminated incorrectly 194 строка extern "C" int __stdcall PrnOpen(int port, int speed, bool hardware);

Pasha: Похоже, printing.h надо использовать в режиме c++ Те есть, создать модуль xxx.cpp, и собирать его компилятором bcc с параметром -P

Pasha: Можно, конечно, заменить во всем тексте extern "C" на extern

Dima: Pasha пишет: Можно, конечно, заменить во всем тексте extern "C" на extern Заменил , но теперь Error Printing.lib contains invalid OMF record ,type 0x21 (possibly COFF)

Dima: Допер ;) implib dtxprint.lib Printing.dll Принтер печатает :) Павел спасибо большое !!!!!!!!!!!!!!!!

Pasha: Дошли до линковки. Линкер поперхнулся либой И это поборем :) если либа не линкуется, то сделаем ее сами командой: implib printing.lib printing.dll

Pasha: У дураков мысли сходятся :)

Dima: Павел а как убрать из линковки библы , что бы все собралось Не нужны следующие dbfntx.lib dbffpt.lib hsx.lib hbsix.lib Хотелось бы максимум убрать все не используемые LIB , так как это будет прога которая будет получать на вход параметры и просто печатать на принтере. Запускать ее буду из Clipper

Петр: Dima пишет: dbfntx.lib dbffpt.lib hsx.lib hbsix.lib Как и в Clipper - ANNOUNCE RDDSYS

Dima: Петр Спасибо !!!

Dima: Что то застрял на ровном месте Программу вызываю из командной строки с параметрами Dtx 4 57600 test.txt Кусок исходника [pre2] Proc main() param nport,speed,cfile ? nport // 4 ? speed // 57600 ? cfile // test.txt if dtx_prnopen(nport,speed,.t.)==0 // не работает * так работает dtx_prnopen(4,57600,.t.) [/pre2]

Pasha: Dima пишет: if dtx_prnopen(nport,speed,.t.)==0 // не работает Наверное надо вызывать val(nport), val(speed)

Dima: Pasha Блин.............пойду проветрюсь Спасибо !

Dima: Pasha Есть дурацкий вопрос. После того как я завершаю программу не нужно ли делать что то типа DllUnload ? Текст программы [pre2] ANNOUNCE RDDSYS Proc main(nport,speed,cfile) if DTX_PRNOPEN(val(nport),val(speed),.t.)==0 if hb_fuse(cfile)#0 do while !hb_feof() DTX_PRNTEXT(hb_freadln()) hb_fskip() enddo hb_fuse() DTX_PRNPAPERFEED(40) DTX_PRNPApERCUT() endif DTX_PRNCLOSE() ferase(cfile) endif return #pragma BEGINDUMP #include "hbapi.h" #define bool char #include "printing.h" HB_FUNC( DTX_PRNOPEN ) { hb_retnl( PrnOpen( hb_parnl(1), hb_parnl(2), hb_parl(3)) ); } HB_FUNC( DTX_PRNCLOSE ) { hb_retnl( PrnClose() ); } HB_FUNC( DTX_PRNPAPERCUT ) { hb_retnl( PrnPaperCut() ); } HB_FUNC( DTX_PRNPAPERFEED ) { hb_retnl( PrnPaperFeed(hb_parnl(1)) ); } HB_FUNC( DTX_PRNTEXT ) { hb_retnl( PrnText(hb_parc(1)) ); } HB_FUNC( DTX_PRNBARCODE ) { hb_retnl( PrnBarcode(hb_parnl(1), hb_parc(2), hb_parclen(2)) ); } #pragma ENDDUMP [/pre2]

Pasha: Нет, в таком режиме линковки dll подгружается сразу, вместе с основной программой, и выгружать ее отдельно не надо

Dima: Pasha Понял , спасибо.

Dima: Dima пишет: implib dtxprint.lib Printing.dll А в MinGw что является аналогом Implib ?

alkresin: Dima пишет: А в MinGw что является аналогом Implib ? http://www.mingw.org/wiki/CreateImportLibraries Если вкратце, то создаем руками текстовый файл ( я буду на примере letocl.dll ) letocl.def: LIBRARY letocl.dll EXPORTS LetoInit LetoExit LetoConnectionNew LetoCloseAll где, начиная с третьей строчки, имена импортируемых функций. А потом запускаем: dlltool -d letocl.def -l libletocl.a

Dima: alkresin пишет: где, начиная с третьей строчки, имена импортируемых функций Понял. Спасибо, а где их взять эти имена ? Нужны все.

alkresin: Ну, например, борландовским impdef: impdef.exe letocl.def letocl.dll

Dima: alkresin Спасибо. Нарыл как с mingw , вот так c:\mingw\bin\ld --output-def=test.def Printing.dll

Dima: Библу собрал а вот со сборкой (Harbour 3.2 + Mingw) засада , хотя нормик собиралось на Xharbour 1.2 + BCC 55 Исходник такой [pre2] Proc main(nport,speed,cfile) if DTX_PRNOPEN(val(nport),val(speed),.t.)==0 if hb_fuse(cfile)#0 do while !hb_feof() DTX_PRNTEXT(hb_freadln()) hb_fskip() enddo hb_fuse() DTX_PRNPAPERFEED(40) DTX_PRNPApERCUT() *dtx_prntext("{=F2}Блаблабла") endif DTX_PRNCLOSE() ferase(cfile) endif return #pragma BEGINDUMP #include "hbapi.h" #define bool char #include "printing.h" HB_FUNC( DTX_PRNOPEN ) { hb_retnl( PrnOpen( hb_parnl(1), hb_parnl(2), hb_parl(3)) ); } HB_FUNC( DTX_PRNCLOSE ) { hb_retnl( PrnClose() ); } HB_FUNC( DTX_PRNPAPERCUT ) { hb_retnl( PrnPaperCut() ); } HB_FUNC( DTX_PRNPAPERFEED ) { hb_retnl( PrnPaperFeed(hb_parnl(1)) ); } HB_FUNC( DTX_PRNTEXT ) { hb_retnl( PrnText(hb_parc(1)) ); } HB_FUNC( DTX_PRNBARCODE ) { hb_retnl( PrnBarcode(hb_parnl(1), hb_parc(2), hb_parclen(2)) ); } #pragma ENDDUMP [/pre2] И вот что вылазит при сборке [pre2] Harbour 3.2.0dev (Rev. 18920) Copyright (c) 1999-2013, http://harbour-project.org/ Compiling 'dtx.prg'... Lines 58, Functions/Procedures 1 Generating C source output to 'obj\dtx.c'... Done. dtx.prg: In function 'HB_FUN_DTX_PRNTEXT': dtx.prg:49:5: warning: passing argument 1 of 'PrnText' discards 'const' qualifier from pointer target type [enabled by d efault] In file included from dtx.prg:22:0: c:/hb32mingw/include/printing.h:269:22: note: expected 'char *' but argument is of type 'const char *' dtx.prg: In function 'HB_FUN_DTX_PRNBARCODE': dtx.prg:56:5: warning: passing argument 2 of 'PrnBarcode' discards 'const' qualifier from pointer target type [enabled b y default] In file included from dtx.prg:22:0: c:/hb32mingw/include/printing.h:408:21: note: expected 'char *' but argument is of type 'const char *' obj/dtx.o:dtx.c:(.text+0x13): undefined reference to `PrnText@4' obj/dtx.o:dtx.c:(.text+0x43): undefined reference to `PrnPaperFeed@4' obj/dtx.o:dtx.c:(.text+0x64): undefined reference to `PrnPaperCut@0' obj/dtx.o:dtx.c:(.text+0x84): undefined reference to `PrnClose@0' obj/dtx.o:dtx.c:(.text+0xe2): undefined reference to `PrnOpen@12' obj/dtx.o:dtx.c:(.text+0x15f): undefined reference to `PrnBarcode@12' C:\MinGW\bin\ld.exe: obj/dtx.o: bad reloc address 0x0 in section `.data' [/pre2]

Dima: Если собирать с Harbour 3.2+ BCC то собирается.........но мне нужно все таки с Mingw Куда копнуть ?

Петр: dlltool -d letocl.def -l libletocl.a -k

Dima: Петр пишет: dlltool -d letocl.def -l libletocl.a -k в сборке это не помогло.......... ошибки те же

Петр: Может эта статья чем-то поможет: http://www.mingw.org/wiki/CreateImportLibraries Я, когда-то, вот так библиотеки импортировал :export pexports %ICU_PATH%/bin/%~n1.dll > %~n1.def dlltool --input-def %~n1.def --dllname %~n1.dll --output-lib lib%~n1.a -k ranlib lib%~n1.a exit /b Правда не знаю: pexports еще развивается или нет, в и-нете, наверное, найти можно..

alkresin: А Dima пишет: obj/dtx.o:dtx.c:(.text+0x13): undefined reference to `PrnText@4' obj/dtx.o:dtx.c:(.text+0x43): undefined reference to `PrnPaperFeed@4' А в def файле у вас функции как описаны, с этими @4 или просто имена, как я вам предлагал ?

Dima: alkresin Просто как имена. Вот кусочек [pre2] LIBRARY Printing.dll EXPORTS BarcodeScan BarcodeType2Text MFAuthByKey MFClose MFHaltCard MFIdent MFInit MFRGetSerial MFRead MFRequestCard MFSelectCard MFValueOperation MFWrite MFWriteValue MSProcessFinancialCard MSReadCard PrnBarcode [/pre2]

alkresin: Попробуйте описать их так, как стоит в undefined reference

Dima: alkresin пишет: Попробуйте описать их так, как стоит в undefined reference Так и сделал в DEF , пересобрал либу. Все заработало. Странно все это. Спасибо !

Dima: Pasha Паш наверное вопрос к тебе. Решили этот принтер расшарить по сетке. Пробная печать из винды идет а из программы не в какую. Это у них SDK такой что не позволяет работать по сетке с этим принтером ? PS Хотя как бы и понятно почему не работает из программы , она (с помощью SDK) пишет в порт а тест винды общается с сетевым принтером.

Pasha: Столько лет уже этой теме, я и подзабыл к чему она. Да и SDK уже недоступен Просто мысль: если этот принтер расшарен как обычный сетевой принтер, может и печатать на него стоит обычными средствами вывода на принтер windows ?

Dima: Pasha SDK они переложили вот сюда http://www.datecs.bg/en/products/56 Закладка SUPPORT. Сам принтер с последовательным интерфейсом и использует свои спец команды для вывода на печать включая форматирование текста , печать штрих кодов и тд и тп. Собственно принтер для печати чеков. За идею спасибо , нужно обмозговать........жаль принтера нет под рукой живого.

Dima: Из мануала [pre2] The printer supports only software (XON/XOFF) protocol. Data reception is disabled when the buffer is close to its upper limit. Reception is re-enabled when the number of bytes in the buffer is below some limit. The printer sends special control characters – XON (11h) to enable and XOFF (13h) to disable transmission. [/pre2] Вероятно по сетке он пахать не будет правильно если я верно понял по англицки.

Dima: Проблему решил. За идею спасибо Has Создал программу (службу) которая обслуживает этот принтер по сети.



полная версия страницы