From b3e13ac69de63f3b993eb4b9866180eac60f3201 Mon Sep 17 00:00:00 2001 From: bandit-ibayashi Date: Tue, 6 Feb 2024 15:41:02 +0900 Subject: [PATCH] CPUtil v1.1.2 / php_queue v2.0.0 --- CloudPRNTSDKSamples/CloudPRNTSDKSamples.sln | 0 CloudPRNTSDKSamples/cputil/Program.cs | 14 +- CloudPRNTSDKSamples/cputil/Readme_En.txt | 403 ++++++++++++++++++ CloudPRNTSDKSamples/cputil/Readme_Jp.txt | 366 ++++++++++++++++ CloudPRNTSDKSamples/cputil/cputil.csproj | 8 +- .../cputil/nupkg_apply_cmd_note.txt | 6 + CloudPRNTSDKSamples/cputil/publish.bat | 5 + CloudPRNTSDKSamples/readme.md | 120 +++--- .../php_queue/cloudprnt-setting.json | 5 + .../cloudprnt-setting_http.json | 5 + .../cloudprnt-setting_mqtt.json | 17 + .../cloudprnt-setting_mqtt_triggerpost.json | 17 + ExampleServers/php_queue/cloudprnt.php | 200 +++------ ExampleServers/php_queue/cpphp.css | 1 + ExampleServers/php_queue/cputil.php | 102 +++++ ExampleServers/php_queue/devices.php | 25 +- ExampleServers/php_queue/js/management.js | 30 +- ExampleServers/php_queue/management.php | 33 ++ .../mqtt_handle_received_message.php | 105 +++++ ExampleServers/php_queue/mqtt_publish.php | 139 ++++++ ExampleServers/php_queue/mqtt_subscribe.ps1 | 14 + ExampleServers/php_queue/mqtt_subscribe.sh | 19 + ExampleServers/php_queue/print.html | 58 ++- ExampleServers/php_queue/print.php | 90 +++- ExampleServers/php_queue/queues.php | 2 + ExampleServers/readme.md | 54 ++- LICENSE | 154 +++++-- README.md | 12 +- docs/README_JP.md | 8 +- 29 files changed, 1742 insertions(+), 270 deletions(-) mode change 100644 => 100755 CloudPRNTSDKSamples/CloudPRNTSDKSamples.sln mode change 100644 => 100755 CloudPRNTSDKSamples/cputil/Program.cs create mode 100755 CloudPRNTSDKSamples/cputil/Readme_En.txt create mode 100755 CloudPRNTSDKSamples/cputil/Readme_Jp.txt mode change 100644 => 100755 CloudPRNTSDKSamples/cputil/cputil.csproj create mode 100755 CloudPRNTSDKSamples/cputil/nupkg_apply_cmd_note.txt create mode 100755 CloudPRNTSDKSamples/cputil/publish.bat create mode 100755 ExampleServers/php_queue/cloudprnt-setting.json create mode 100755 ExampleServers/php_queue/cloudprnt-setting_Sample/cloudprnt-setting_http.json create mode 100755 ExampleServers/php_queue/cloudprnt-setting_Sample/cloudprnt-setting_mqtt.json create mode 100755 ExampleServers/php_queue/cloudprnt-setting_Sample/cloudprnt-setting_mqtt_triggerpost.json create mode 100755 ExampleServers/php_queue/cputil.php create mode 100755 ExampleServers/php_queue/management.php create mode 100755 ExampleServers/php_queue/mqtt_handle_received_message.php create mode 100755 ExampleServers/php_queue/mqtt_publish.php create mode 100755 ExampleServers/php_queue/mqtt_subscribe.ps1 create mode 100755 ExampleServers/php_queue/mqtt_subscribe.sh diff --git a/CloudPRNTSDKSamples/CloudPRNTSDKSamples.sln b/CloudPRNTSDKSamples/CloudPRNTSDKSamples.sln old mode 100644 new mode 100755 diff --git a/CloudPRNTSDKSamples/cputil/Program.cs b/CloudPRNTSDKSamples/cputil/Program.cs old mode 100644 new mode 100755 index 1d9dfbe..ba4847a --- a/CloudPRNTSDKSamples/cputil/Program.cs +++ b/CloudPRNTSDKSamples/cputil/Program.cs @@ -212,6 +212,10 @@ static void Main(string[] args) opts.SupportUTF8 = true; break; + case "sbcs": + opts.SupportUTF8 = false; + break; + case "scale-to-fit": opts.ScaleToFit = true; break; @@ -274,7 +278,8 @@ static void PrintHelp() " matrix69.5 - set device constraints for a dot-matrix 69.5mm\" printer", " matrix3/matrix76 - set device constraints for a dot-matrix 76mm/3\" printer", " printarea - set device constraints for a specified printable area dot size of printer", - " utf8 - specify that the target device supports UTF8 encoding", + " utf8 - specify that the target device supports UTF8 encoding (default)", + " sbcs - specify that the target device supports only single byte codepages", " dither - specify that colour/greyscale images should be ditherer", " scale-to-fit - specify that any images which exceed the device width", " should be resized to fit the page.", @@ -321,9 +326,12 @@ static void DisplayInfo() Assembly a = typeof(StarMicronics.CloudPrnt.Document).Assembly; AssemblyName n = a.GetName(); Version v = n.Version; - + Console.WriteLine("{0}: {1}.{2}.{3}.{4}", n.Name, v.Major, v.Minor, v.Build, v.Revision); - Console.WriteLine("cputil: 1.1.0.0"); + + AssemblyName cn = Assembly.GetExecutingAssembly().GetName(); + Version cv = cn.Version; + Console.WriteLine($"{cn.Name}: {cv.Major}.{cv.Minor}.{cv.Build}.{cv.Revision}"); } static void PrintInputs() diff --git a/CloudPRNTSDKSamples/cputil/Readme_En.txt b/CloudPRNTSDKSamples/cputil/Readme_En.txt new file mode 100755 index 0000000..a014728 --- /dev/null +++ b/CloudPRNTSDKSamples/cputil/Readme_En.txt @@ -0,0 +1,403 @@ +************************************************************ + cputil Ver 1.1.2 28/04/2022 + Readme_En.txt Star Micronics Co., Ltd. +************************************************************ + + 1. Overview + 2. Contents + 3. Scope + 4. Usage Example + 5. Limitation + 6. OSS Licenses + 7. Copyright + 8. Release History + +============= + 1. Overview +============= + + This package contains cputil Ver 1.1.2. + cputil is intented to serve and a useful back-end tool to help + with implementing CloudPRNT servers that are not .NET or .NET Core based. + + cputil can be use on any platform supported by .NET 6.0 including: + - Windows x86 and x64 ... cputil-win-x86_v112.zip / cputil-win-x64_v112.zip + - Linux x64 ... cputil-linux-x64_v112.tar.gz + - Apple Mac OS (OSX) x64 (Except 10.15 or later) ... cputil-osx-x64_v112.tar.gz + - Apple Mac OS (OSX) x64 (10.15 or later) ... cputil-osx-x64_v112.zip + - Linux Arm (Raspberry PI compatible) ... cputil-linux-arm_v112.tar.gz + + In all cases, it is possible to build a self contained package that can be + run on the desired platform without the need for a .NET Framework or .NET Core + installation. + + Please refer to SDK documents for details. + (https://www.star-m.jp/products/s_print/CloudPRNTSDK/Documentation/en/index.html) + +============= + 2. Contents +============= + + cputil-_v112.zip(or .tar.gz) + |- Readme_En.txt // Release Notes (English) + |- Readme_Jp.txt // Release Notes (Japanese) + |- SoftwareLicenseAgreement.pdf // Software License Agreement (English) + |- SoftwareLicenseAgreement_Jp.pdf // Software License Agreement (Japanese) + |- SoftwareLicenseAgreementAppendix.pdf // Software License Agreement Appendix + | + +- cputil- + |- cputil(.exe) // cputil executable file + +========== + 3. Scope +========== + cputil can be use on any platform supported by .NET 6.0 including: + - Windows x86 and x64 ... cputil-win-x86_v112.zip / cputil-win-x64_v112.zip + - Linux x64 ... cputil-linux-x64_v112.tar.gz + - Apple Mac OS (OSX) x64 (Except 10.15 or later) ... cputil-osx-x64_v112.tar.gz + - Apple Mac OS (OSX) x64 (10.15 or later) ... cputil-osx-x64_v112.zip + - Linux Arm (Raspberry PI compatible) ... cputil-linux-arm_v112.tar.gz + + Works with these CloudPRNT client printers: + - mC-Print2 + - mC-Print3 + - TSP100IV + - TSP650II with IFBD-HI01X + - TSP700II with IFBD-HI01X + - TSP800II with IFBD-HI01X + - TSP650IISK with IFBD-HI01X(V1.9.0 or later) + - SP700 with IFBD-HI02X + + Please refer to each CloudPRNT client printer for details. + You can check the manual from Star web site. + (https://www.star-m.jp/products/s_print/CloudPRNTSDK/Documentation/en/developerguide/introduction.html) + +================== + 4. Usage Example +================== + + The example of usages for cputil are like below. + + And it also can be refer to SDK documents for details. + (https://www.star-m.jp/products/s_print/CloudPRNTSDK/Documentation/en/articles/cputil/cputil_usage.html) + + ### Installation + Please unzip/extract cputil-.zip(or .tar.gz) to any specified path on PC. + (Installation location and method is entirely the choice of the server administrator) + + The below operation is to test this "Usage Example". + Please open the terminal or command prompt on each PC and perform following command. + + [Windows] + > cd \cputil-win-x64_v112\cputil-win-x64 + or + > cd \cputil-win-x86_v112\cputil-win-x86 + + [Linux] + $ cd /cputil-linux-x64 + + [macOS] + $ cd /cputil-osx-x64 + + Notes: + On macOS 10.15 or later, cputil will be installed by Star provided pkg installer. + Therefore just input "cputil" is enough when perform cputil command on terminal + for below example(No need "./"). + + ### Decoding Star ASB Status + + Star CloudPRNT devices will report their status in Star ASB format, as a + string of 7 or more hexadecimal values. For Example: + > "23 86 00 00 00 00 00 00 00 00 00" + + This is not easy to decode in all languages, and do cputil provides a method + to convert this into JSON format data, e.g.: + + [Windows] + > .\cputil.exe jsonstatus "23 86 00 00 00 00 00 00 00 00 00" + + [Linux / macOS] + $ ./cputil jsonstatus "23 86 00 00 00 00 00 00 00 00 00" + + will generate the output: + > { + > "Online": true, + > "CoverOpen": false, + > "CompulsionSwitch": false, + > "OverTemperature": false, + > "Recoverable": true, + > "CutterError": false, + > "MechanicalError": false, + > "ReceiveBufferOverflow": false, + > "BlackMarkError": false, + > "PresenterPaperJam": false, + > "VoltageError": false, + > "PaperEmpty": false, + > "PaperLow": false + > } + + + ### Handling Print Job media formats + + cputil can help with key parts of the CloudPRNT printing process. A server + can prepare a print job in a single input format, which may not be natively + supported by the \cloudPRNT client device. The server can then use cputil to + convert the job, as needed to a format that the CloudPRNT client does support. + + Supported input print job media formats are: + * Images + * PNG - image/png + * Jpeg - image/jpeg + * BMP - image/bmp + * GIF - image/gif + * Plain Text - text/plain + * Star Document Markup - text/vnd.star.markup + + + #### generating the mediaTypes field + + When a CloudPRNT compatible server has a print job ready for a particular + client (typically a Star mC-Print2, mC-Print3 or printer with HI0x interface + card), the it must: + * wait for a poll request from the client (a JSON request sent by http POST) + * reply to the client with a suitable json response, with at least the fields: + * @jobReady@ set to true. + * @mediaTypes@ an array of media type names in which the job can be provided + to the client. + + For example: + > { + > "jobReady": true, + > "mediaTypes": ["image/jpeg", "image/png"] + > } + + At this point in the job printing negotiation, cputil can be used to prepare + the mediaTypes list, based on the input format that the server plans to use. + + For example, for a server that will use a PNG image as the initial print job + source,use (In this sample, sourceimage.png is the name of the input file. + Please prepare and put the file to directory same as cputil executable): + + [Windows] + > .\cputil.exe mediatypes sourceimage.png + + [Linux / macOS] + $ ./cputil mediatypes sourceimage.png + + which will generate the JSON ready output: + > ["image/png","image/jpeg","application/vnd.star.raster","application/vnd.star.line","application/vnd.star.starprnt","application/vnd.star.starprntcore"] + + + ### Converting a job for printing + + After a server has provided a JSON response to the CloudPRNT poll with the + jobReady field set to true, and a valid mediaTypes list, the client will + recognise that it is there is a job for it to print. it will perfom the + following steps: + * select its preferred mediaType, from those available in the list. This + is typically selected based on the first format in the list which is supported + by the client. However, the exact decision can be client specific. + * perform an http GET to the CloudPRNT server to retrieve the job, specifying + the chosen mediaType through a query string parameter. + + When the server receives the http GET, it should return the job to be printer + encoded with the requested media type. + + Servers can prepare the job in a single, internally preferred format and then + use cputil to convert it to the requested format. + + For example, if a server has prepared a print job as png data, and the client + requests it as StarPRNT printer command data (application/vnd.star.starprnt) + then cputil can be used: + + [Windows] + > .\cputil.exe decode "application/vnd.star.starprnt" sourceimage.png outputdata.bin + + [Linux / macOS] + $ ./cputil decode "application/vnd.star.starprnt" sourceimage.png outputdata.bin + + Which will convert the png input file into printer command data stored in + "outputdata.bin". If it is more convenient to write the output data to standard + output, then use either "-" ot "[stdout]" as the output file name. + + And also, if a server has prepared a print job as star document markup + text data(filename extension is ".stm"), and the client requests it + as StarPRNT printer command data (application/vnd.star.starprnt) + then cputil can be used: + + [Windows] + > .\cputil.exe decode application/vnd.star.starprnt starmarkup.stm outputdata.bin + + [Linux / macOS] + $ ./cputil decode application/vnd.star.starprnt starmarkup.stm outputdata.bin + + Which will convert the star document markup input file("starmarkup.stm") + into printer command data stored in "outputdata.bin". + + And this outputdata.bin can print on the starprnt emulation printer(mC-Print2/3) + via 9100 port / CloudPRNT print job etc. + + + ### Conversion options + + Conversion can include image scaling or cropping and dithering. + For scaling and cropping to work, it is necessary to inform cputil of the + printer print width. CloudPRNT servers can obtain this information through + the CloudPRNT clientAction "PageInfo" request. + + To specify the print area size, use one of the following options: + * "thermal2" or "thermal58" - set the print area to that of a 2inch/58mm printer, + such as the mC-Print2. + * "thermal3" or "thermal80" - set the print area to that of a 3inch/80mm printer, + such as a TSP650II or mC-Print3. + * "thermal4" or "thermal112" - set the print area to that of a 4inch/112mm + printer, such as the Star TSP800II. + + To specify dithering, use the option "dither". + To specify that the image should be scaled to fit the print area, use the + "scale-to-fit" option. Otherwise the image will be unscales, but cropped if it + is wider than the print area. + + For example, to prepare print data as StarPRNT commands for a 2inch printer + from a PNG source, with dithering and the image scaled to fit the page: + + [Windows] + For 2inch printer(mC-Print2): + > .\cputil.exe thermal2 dither scale-to-fit decode "application/vnd.star.starprnt" sourceimage.png outputdata_2.bin + + For 3inch printer(mC-Print3): + > .\cputil.exe thermal3 dither scale-to-fit decode "application/vnd.star.starprnt" sourceimage.png outputdata_3.bin + + [Linux / macOS] + For 2inch printer(mC-Print2): + $ ./cputil thermal2 dither scale-to-fit decode "application/vnd.star.starprnt" sourceimage.png outputdata_2.bin + + For 3inch printer(mC-Print3): + $ ./cputil thermal3 dither scale-to-fit decode "application/vnd.star.starprnt" sourceimage.png outputdata_3.bin + + + When converting to output formats that are able to include device commands + (e.g. application/vnd.star.line, application/vnd.star.starprnt). + It is possible to ask cputil to include commands to trigger a printer + connected cash drawer(or buzzer) to open(or ring) with the following options: + * "drawer-start" - Open a drawer at the start of the print job. + * "drawer-end" - Open a drawer at the end of the print job. + * "drawer-none" - Do not open a connected cash drawer (default). + + * "buzzer-start X (X is numeric)" - Ring a buzzer by specified times at the start of the print job. + * "buzzer-end X (X is numeric)" - Ring a buzzer by specified times at the end of the print job. + + [Notes] + Certain output data formats do not support embeding device commands, such as text/plain, image/png, image/jpeg. + In these cases it is possible to use the CloudPRNT protocol to request that a cash drawer is opened + via the http print job response header. Alternatively, ensure that your CloudPRNT service uses device command print job formats. + + For example, to prepare print data as StarPRNT commands for a 2 inch printer from a PNG source, + with cashdrawer open(2inch) and buzzer ring at the end of job: + + [Windows] + For 2inch printer(mC-Print2): + > .\cputil.exe thermal2 scale-to-fit drawer-end decode "application/vnd.star.starprnt" sourceimage.png outputdata_2.bin + + For 3inch printer(mC-Print3): + > .\cputil.exe thermal3 scale-to-fit buzzer-end 1 decode "application/vnd.star.starprnt" sourceimage.png outputdata_3.bin + + [Linux / macOS] + For 2inch printer(mC-Print2): + $ ./cputil thermal2 scale-to-fit drawer-end decode "application/vnd.star.starprnt" sourceimage.png outputdata_2.bin + + For 3inch printer(mC-Print3): + $ ./cputil thermal3 scale-to-fit buzzer-end 1 decode "application/vnd.star.starprnt" sourceimage.png outputdata_3.bin + + + To enable a hold print feature + This feature is available with TSP650IISK and IFBD-HI01X (Ver 1.9.0 or later). + TSP650IISK has hold print feature which can be detected if remains a printed receipt at paper exit. + The below options can be specified whehter informs hold print status / enable hold print firmware control + (These settings are actually affects after sending current job(from next time print job)). + + * `presentstatus-default` - Follows printer firmware setting about the informing of hold print status. + * `presentstatus-valid` - Enables about the informing the hold print status. + * `presentstatus-invalid` - Disables about the informing the hold print status. + + * `holdprint-default` - Follows printer firmware setting about the controlling the hold print function by hardware. + * `holdprint-valid` - Enables about the controlling the hold print function by hardware. + * `holdprint-invalid` - Disables about the controlling the hold print function by hardware. + + For example, to prepare print data as StarPRNT commands for a 2 inch printer from a PNG source, + with enabling hold print status and disabling hold print firmware control: + + [Windows] + For 2inch printer(mC-Print2): + > .\cputil.exe thermal2 scale-to-fit presentstatus-valid holdprint-invalid decode application/vnd.star.starprnt sourceimage.png outputdata_2.bin + + For 3inch printer(mC-Print3): + > .\cputil.exe thermal3 scale-to-fit presentstatus-valid holdprint-invalid decode application/vnd.star.starprnt sourceimage.png outputdata_3.bin + + [Linux / macOS] + For 2inch printer(mC-Print2): + $ ./cputil thermal2 scale-to-fit presentstatus-valid holdprint-invalid decode "application/vnd.star.starprnt" sourceimage.png outputdata_2.bin + + For 3inch printer(mC-Print3): + $ ./cputil thermal3 scale-to-fit presentstatus-valid holdprint-invalid decode "application/vnd.star.starprnt" sourceimage.png outputdata_3.bin + + [Notes] + About holdpirnt-XXX options, this option is recommended to set invalid when use software solutions(like CloudPRNT) + supporting TSP650IISK feature. Because these softwares controls the hold print feature by hold print status. + Certain output data formats do not support embeding device commands, such as text/plain, image/png, image/jpeg. + In these cases it is possible to use the CloudPRNT protocol to request that a cash drawer is opened via the http print job response header. + Alternatively, ensure that your CloudPRNT service uses device command print job formats. + + +=============== + 5. Limitation +=============== + + 1. Word wrapping / column command for starmarkup features with Unicode character are only supported + by mC-Print2 / mC-Print3 / TSP650II. + +================= + 6. OSS Licenses +================= + cputil package includes these libraries which is included OSS licenses. + + .NET core (MIT License) : https://github.com/dotnet/core/blob/master/LICENSE.TXT + SixLabors.ImageSharpe (Apache License) : http://www.apache.org/licenses/LICENSE-2.0 + Newtonsoft.Json (MIT License) : https://github.com/dotnet/core/blob/master/LICENSE.TXT + +============== + 7. Copyright +============== + + Copyright 2020 Star Micronics Co., Ltd. All rights reserved. + +==================== + 8. Release History +==================== + + Ver 1.1.2 + 2022/04/28: + Update the SixLabors.ImageSharp library from V1.0.2 to V1.0.4 to support .NET 6.0 environment. + Update the Newtonsoft.Json library from V12.0.3 to V13.0.1. + Update the .NET framework from .NET Core 3.1 to .NET 6.0. + + Ver 1.1.1 + 2021/01/18: + Update the SixLabors.ImageSharp library from V100-beta007 to V1.0.2. + Update the .NET Core framework from 2.1 to 3.1. + Improve the long data URLs length limit in Markup. + Support for the sbcs option in cputil for models that do not support utf8 code pages. + + Ver.1.1.0 + 2020/06/17: + Support the command option of drawer for controlling CashDrawer. + Support the command option of buzzer for controlling Buzzer. + Support embedded data urls for [image] markup tag. + Support [negative] markup tag to printing colour inverted text. + Support [invert] markup tag to support upside-down printing. + Support the command options of holdprint and presentstatus for TSP650IISK model. + + Ver.1.0.0 + 2019/11/05: + First release. + diff --git a/CloudPRNTSDKSamples/cputil/Readme_Jp.txt b/CloudPRNTSDKSamples/cputil/Readme_Jp.txt new file mode 100755 index 0000000..d57485c --- /dev/null +++ b/CloudPRNTSDKSamples/cputil/Readme_Jp.txt @@ -0,0 +1,366 @@ +************************************************************ + cputil Ver 1.1.2 2022/04/28 + Readme_Jp.txt スター精密(株) +************************************************************ + + 1. 概要 + 2. 内容 + 3. 適用 + 4. 使用例 + 5. 制限事項 + 6. OSSライセンス情報 + 7. 著作権 + 8. 変更履歴 + +========== + 1. 概要 +========== + + 本パッケージは、cputil V1.1.2 です。 + cputil は、.NET Frameworkまたは .NET Core ベースではない CloudPRNTサーバーの実装に役立つ + 便利なバックエンド ツールとして機能することを目的としています。 + + cputilは、.NET 6.0を用いて実装しております。 + + このため、 +   .NET 6.0に対応したプラットフォームで利用出来ます。 +  cputilを利用するPCにて、.NET Frameworkのインストールは不要です。 + + 具体的にcputilを利用できるプラットフォームは以下の通りです。 + - Windows x86 and x64 ... cputil-win-x86_v112.zip / cputil-win-x64_v112.zip + - Linux x64 ... cputil-linux-x64_v112.tar.gz + - Apple Mac OS (OSX) x64 (10.15以降を除く) ... cputil-osx-x64_v112.tar.gz + - Apple Mac OS (OSX) x64 (10.15以降) ... cputil-osx-x64_v112.zip + - Linux Arm (Raspberry PI compatible) ... cputil-linux-arm_v112.tar.gz + + 詳細な説明は、SDKドキュメントファイルを参照ください。 + (https://www.star-m.jp/products/s_print/CloudPRNTSDK/Documentation/ja/index.html) + + +========== + 2. 内容 +========== + + cputil-_v112.zip(or .tar.gz) + |- Readme_En.txt // リリースノート (英語) + |- Readme_Jp.txt // リリースノート (日本語) + |- SoftwareLicenseAgreement.pdf // ソフトウエア使用許諾書 (英語) + |- SoftwareLicenseAgreement_Jp.pdf // ソフトウエア使用許諾書 (日本語) + |- SoftwareLicenseAgreementAppendix.pdf // ソフトウエア使用許諾書別紙 + | + +- cputil- + |- cputil(.exe) // cputil実行可能ファイル + + +========== + 3. 適用 +========== + + 本ソフトウェアは現在、.NET Core 6.0 によってサポートされるプラットフォームに対応しています。 + - Windows x86 and x64 ... cputil-win-x86_v112.zip / cputil-win-x64_v112.zip + - Linux x64 ... cputil-linux-x64_v112.tar.gz + - Apple Mac OS (OSX) x64 (10.15以降を除く) ... cputil-osx-x64_v112.tar.gz + - Apple Mac OS (OSX) x64 (10.15以降) ... cputil-osx-x64_v112.zip + - Linux Arm (Raspberry PI compatible) ... cputil-linux-arm_v112.tar.gz + + いずれの場合も、自己完結型パッケージにてビルドされており、 + .NET Framework または .NET Core のインストールを必要とせずに目的のプラットフォームで実行できます。 + + また、下記のCloudPRNTクライアント対応プリンタを対象としています。: + - mC-Print2 + - mC-Print3 + - TSP100IV + + CloudPRNTについての詳細は、SDKドキュメントファイルを参照ください。 + (https://www.star-m.jp/products/s_print/CloudPRNTSDK/Documentation/ja/developerguide/introduction.html) + + +=============== + 4. 使用例 +=============== + cputilの使用例は以下になります。 + + また、詳細な説明はSDKドキュメントファイルを参照してください。 + (https://www.star-m.jp/products/s_print/CloudPRNTSDK/Documentation/ja/articles/cputil/cputil_usage.html) + + ### インストレーション + PC 上の任意のパスに cputil-<プラットフォーム名>_v112.zip(または .tar.gz)を解凍してください。 + (インストール場所と方法は、PC/サーバー管理者が任意で選択できます) + + 以下の操作は、本使用例をテストするために実施します。 + + PCのコマンドプロンプトもしくはターミナルを起動してください。 + また起動後、次のコマンドを実行してください。 + + [Windows] + > cd \cputil-win-x64_v112\cputil-win-x64 + or + > cd \cputil-win-x86_v112\cputil-win-x86 + + [Linux] + $ cd /cputil-linux-x64 + + [macOS] + $ cd /cputil-osx-x64 + + 備考: + macOS 10.15以降では、cputilはStarが提供するpkgイントーラーによってインストールされます。 + したがって、以下の例でターミナルにてcputilコマンドを実行する場合は、 + 「cputil」と入力してください("./"は不要です)。 + + ### Star ASB ステータスのデコード + + Star CloudPRNTデバイスは、Star ASB形式のステータスを7個以上の16進数値の文字列で通知します。 + 例: + > "23 86 00 00 00 00 00 00 00 00 00" + + これは、言語によってはデコードが難しい場合があります。 + cputilを利用すると、下記のようにJSON形式のデータに変換できます。 + + コマンド例: + [Windows] + > .\cputil.exe jsonstatus "23 86 00 00 00 00 00 00 00 00 00" + + [Linux / macOS] + $ ./cputil jsonstatus "23 86 00 00 00 00 00 00 00 00 00" + + 上記を実行時の標準出力は以下になります: + > { + > "Online": true, + > "CoverOpen": false, + > "CompulsionSwitch": false, + > "OverTemperature": false, + > "Recoverable": true, + > "CutterError": false, + > "MechanicalError": false, + > "ReceiveBufferOverflow": false, + > "BlackMarkError": false, + > "PresenterPaperJam": false, + > "VoltageError": false, + > "PaperEmpty": false, + > "PaperLow": false + > } + + + ### 印刷ジョブメディア形式のハンドリング + + cputil は、CloudPRNT印刷プロセスの部分に利用できます。 + CloudPRNTサーバーが、CloudPRNTクライアントデバイスでネイティブにサポートされていない + 単一の入力形式の印刷ジョブを準備した場合、サーバーはcputilを使用して、必要に応じて + CloudPRNT クライアントがサポートする形式にジョブを変換できます。 + + cputilでサポートされている印刷ジョブの入力メディア形式: + * 画像 + * PNG - image/png + * Jpeg - image/jpeg + * BMP - image/bmp + * GIF - image/gif + * プレーンテキスト - text/plain + * Starドキュメントマークアップ - text/vnd.star.markup + + + #### メディア形式フィールドの生成 + + CloudPRNTサーバーが特定のクライアント (Star mC-Print2、mC-Print3プリンタ) に対して印刷ジョブを準備している場合、 + 次の対応をする必要があります。 + * クライアントからのポーリング要求 (http POST によって送信される JSON 要求) を待機します。 + * mediaTypesフィールドを使用して、適切なjson応答でクライアントに応答します。 + * jobReady - trueに設定 + * mediaTypes - クライアントに印刷ジョブとして提供できるメディア形式の文字列配列 + + 例: + > { + > "jobReady": true, + > "mediaTypes": ["image/jpeg", "image/png"] + > } + + このジョブ印刷ネゴシエーションの時点で、cputilを使用して、サーバーが使用する予定の入力形式に基づいて + mediaTypes リストを準備できます。 + + 例えば、PNG イメージを印刷ジョブソースとして使用するサーバーの場合は次のコマンドを利用してください。 + (この例では sourceimage.png は入力ファイル名です。当該ファイルを準備しcputil実行可能ファイルと同じディレクトリに配置してください) + + コマンド例: + [Windows] + > .\cputil.exe mediatypes sourceimage.png + + [Linux / macOS] + $ ./cputil mediatypes sourceimage.png + + 上記によりJSONレディ文字列の出力を生成します: + > ["image/png","image/jpeg","application/vnd.star.raster","application/vnd.star.line","application/vnd.star.starprnt","application/vnd.star.starprntcore"] + + + ### 印刷ジョブ変換 + jobReadyフィールドをtrueに設定し、有効なmediaTypesリストを使用して、 + サーバーが CloudPRNT POSTポーリングに対するJSON応答を実行すると、 + クライアントは印刷するジョブがサーバーにあることを認識します。 + そして次の手順が実行されます。 + + * プリンタは、提供されたリスト内の使用可能なメディアタイプを選択します。 + これは通常、クライアントでサポートされているmediaTypeリストの最初の形式に基づいて選択されます。 + (使用するメディアタイプの決定はクライアントデバイスに依存します) + + * クエリ文字列パラメーターを使用して選択したmediaTypeを指定して、 + CloudPRNT サーバーに対してhttp GETリクエストを実行して印刷ジョブの取得をします。 + + CloudPRNTサーバーは、http GETリクエストを受け取た場合、要求されたメディア形式でエンコードされた + プリンタの印刷ジョブを返してください。 + + サーバーは内部的に準備した入力データを、cputilを使用して要求されたメディア形式に変換できます。 + + 下記例では、サーバーが印刷ジョブをpngデータとして準備し、クライアントがそれを + StarPRNTコマンドデータ (application/vnd.star.starprnt)として要求した場合、cputilを下記のように使用できます。 + + コマンド例: + [Windows] + > .\cputil.exe decode "application/vnd.star.starprnt" sourceimage.png outputdata.bin + + [Linux / macOS] + $ ./cputil decode "application/vnd.star.starprnt" sourceimage.png outputdata.bin + + 上記は、png入力ファイルをStarPRNTコマンドデータに変換して"outputdata.bin" に出力します。 + 出力データを標準出力に書き込む方が便利な場合は、出力ファイル名として "-" または "[stdout]"に対して + 出力できるよう適宜調整してください。 + + また、サーバーが印刷ジョブをStarドキュメントマークアップ形式のテキストファイル(拡張子は".stm") + として準備しクライアントがそれをStarPRNTプリンターコマンドデータ(application/vnd.star.starprnt) + として要求した場合、cputilを使用してStarドキュメントマークアップデータからStarPRNTコマンドデータへ変換できます: + + [Windows] + > .\cputil.exe decode "application/vnd.star.starprnt" starmarkup.stm outputdata.bin + + [Linux / macOS] + $ ./cputil decode "application/vnd.star.starprnt" starmarkup.stm outputdata.bin + + 上記の場合、入力したStarドキュメントマークアップ形式のテキストファイル("starmarkup.stm")を + StarPRNTコマンドデータ("outputdata.bin"へ保存)に変換します。 + + 尚、この"outputdata.bin"はmC-Print2/3にてTCP9100ポート / CloudPRNT印刷経由等で印刷可能なデータとして + 利用いただけます。 + + + ### 変換オプション + + 変換オプションには、イメージのスケーリングやディザリングを含めることができます。 + スケーリングを機能させるには、プリンタの印刷幅をcputilに指定してください。 + CloudPRNT clientAction "ClientType"や"PageInfo" 要求を通じて + この印刷幅の決定をすることも可能です。 + + 印刷範囲のサイズを指定するため、下記のオプションを指定してください: + * "thermal2" もしくは "thermal58" - 2インチ/58mmプリンタ(mC-Print2) + * "thermal3" もしくは "thermal80" - 3インチ/80mmプリンタ(mC-Print3) + + ディザリングを指定するには、"dither"オプションを使用します。 + 印刷領域に合わせてイメージを拡大縮小するように指定するには"scale-to-fit" オプションを使用します。 + 指定無しの場合、イメージの拡大縮小はせず、ソース画像が印刷範囲よりも広い場合は有効範囲内でトリミングされます。 + (例えば、thermal3指定の場合576ドット幅以降はトリミングされ、印刷されません) + + 下記はPNG画像から、StarPRNTコマンドの印刷データを準備するためのコマンド例です。 + 画像は変換オプションにより、印刷有効範囲にスケールされ、ディザリング処理が実施された + 画像データとしてStarPRNTコマンドデータに変換されます。 + + コマンド例: + [Windows] + 2インチプリンタ(mC-Print2): + > .\cputil.exe thermal2 dither scale-to-fit decode "application/vnd.star.starprnt" sourceimage.png outputdata_2.bin + + 3インチプリンタ(mC-Print3): + > .\cputil.exe thermal3 dither scale-to-fit decode "application/vnd.star.starprnt" sourceimage.png outputdata_3.bin + + [Linux / macOS] + 2インチプリンタ(mC-Print2): + $ ./cputil thermal2 dither scale-to-fit decode "application/vnd.star.starprnt" sourceimage.png outputdata_2.bin + + 3インチプリンタ(mC-Print3): + > ./cputil thermal3 dither scale-to-fit decode "application/vnd.star.starprnt" sourceimage.png outputdata_3.bin + + #### キャッシュドロワー及びブザーの制御 + + デバイスコマンドを含めることができる出力形式に変換する場合(例: application/vnd.star.starprnt)、 + プリンターに接続されたキャッシュドロワー(またはブザー)を制御するために、 + 次のオプションで制御コマンドを含めるようにcputilにて指定することができます。: + * `drawer-start` - 印刷ジョブの開始時にキャッシュドロワーを開きます。 + * `drawer-end` - 印刷ジョブの終了時にキャッシュドロワーを開きます。 + * `drawer-none` - キャシュドロワーの操作はしません (デフォルト)。 + + * `buzzer-start X (Xは数字)` - 印刷ジョブの開始時に指定した回数ブザーを鳴らします。 + * `buzzer-end X (Xは数字)` - 印刷ジョブの終了時に指定した回数ブザーを鳴らします。 + + 例えば、入力PNGソース(またはStarマークアップ形式のテキストファイル)からプリンター用のStarPRNTコマンドとして印刷データを準備し、 + 印刷終了時にキャッシュドロワーを開く(2インチプリンタ)またはブザーを一回鳴らす(3インチプリンタ)設定をする場合は以下になります: + + コマンド例: + [Windows] + 2インチプリンタ(mC-Print2): + > .\cputil.exe thermal2 scale-to-fit drawer-end decode "application/vnd.star.starprnt" sourceimage.png outputdata_2.bin + + 3インチプリンタ(mC-Print3): + > .\cputil.exe thermal3 buzzer-end 1 decode "application/vnd.star.starprnt" starmarkup.stm outputdata_3.bin + + [Linux / macOS] + 2インチプリンタ(mC-Print2): + $ ./cputil thermal2 scale-to-fit drawer-end decode "application/vnd.star.starprnt" sourceimage.png outputdata_2.bin + + 3インチプリンタ(mC-Print3): + > ./cputil thermal3 buzzer-end 1 decode "application/vnd.star.starprnt" starmarkup.stm outputdata_3.bin + + [備考] + 特定の出力データ形式(text/plain、image/png、image/jpegなど)は、デバイスコマンドをサポートしていません。 + このような場合、CloudPRNTプロトコルを使用してhttp印刷ジョブの応答ヘッダー(GETレスポンスヘッダー)を利用して + キャッシュドロワーまたはブザーを制御するように指定してください。 + + +=============== + 5. 制限事項 +=============== + + 特筆事項なし + + +====================== + 6. OSSライセンス情報 +====================== + + cputilパッケージは以下のOSSライセンスを含むライブラリを使用しております。 + + .NET core (MIT License) : https://github.com/dotnet/core/blob/master/LICENSE.TXT + SixLabors.ImageSharpe (Apache License): http://www.apache.org/licenses/LICENSE-2.0 + Newtonsoft.Json (MIT License) : https://github.com/dotnet/core/blob/master/LICENSE.TXT + + +=========== + 7. 著作権 +=========== + + スター精密(株)Copyright 2020 + + +============= + 8. 変更履歴 +============= + + Ver 1.1.2 + 2022/04/28: +   SixLabors.ImageSharpライブラリを.NET 6.0環境に対応するためV1.0.2からV1.0.4へ更新 + Newtonsoft.JsonライブラリをV12.0.3からV13.0.1へ更新 + .NET フレームワークを.NET Core 3.1から .NET 6.0へ更新 + + Ver 1.1.1 + 2021/01/18: +  画像処理のためのSixLabors.ImageSharpライブラリをV100-beta007からV1.0.2へ更新 + .NET CoreフレームワークをV2.1からV3.1へ更新 + [image]タグにおける指定できる埋込みデータURL長を改善 + UTF8コードページをサポートしていない機種のためのsbcsコマンドオプションをサポート + + Ver.1.1.0 + 2020/06/17: + キャッシュドロワー制御のための「drawer」コマンドオプションをサポート + ブザー制御のための「buzzer」コマンドオプションをサポート + 埋め込みデータURLを[image]タグでサポート + 白黒反転印字のための[negative]タグをサポート + 倒立印字のための[invert]タグをサポート + + Ver.1.0.0 + 2019/11/05: + 初版リリース diff --git a/CloudPRNTSDKSamples/cputil/cputil.csproj b/CloudPRNTSDKSamples/cputil/cputil.csproj old mode 100644 new mode 100755 index b7af3c3..46f37ac --- a/CloudPRNTSDKSamples/cputil/cputil.csproj +++ b/CloudPRNTSDKSamples/cputil/cputil.csproj @@ -2,16 +2,16 @@ Exe - netcoreapp2.1 + net6.0 Star Micronics Star Micronics Copyright 2020 Star Micronics Co., Ltd. - 1.1.0 + 1.1.2 - - + + diff --git a/CloudPRNTSDKSamples/cputil/nupkg_apply_cmd_note.txt b/CloudPRNTSDKSamples/cputil/nupkg_apply_cmd_note.txt new file mode 100755 index 0000000..519069f --- /dev/null +++ b/CloudPRNTSDKSamples/cputil/nupkg_apply_cmd_note.txt @@ -0,0 +1,6 @@ +The following commands should do before performing "./package.sh" to apply latest making nupkg. + +commands: +nuget locals all -clear +nuget add StarMicronics.CloudPRNT-Utility.1.1.2.nupkg -Source ./packages +dotnet add package StarMicronics.CloudPRNT-Utility -s ./packages -v 1.1.2 diff --git a/CloudPRNTSDKSamples/cputil/publish.bat b/CloudPRNTSDKSamples/cputil/publish.bat new file mode 100755 index 0000000..34b18cd --- /dev/null +++ b/CloudPRNTSDKSamples/cputil/publish.bat @@ -0,0 +1,5 @@ +dotnet publish -o package\cputil-linux-arm -c Release -r linux-arm +dotnet publish -o package\cputil-linux-x64 -c Release -r linux-x64 +dotnet publish -o package\cputil-win-x64 -c Release -r win-x64 +dotnet publish -o package\cputil-win-x86 -c Release -r win-x86 +dotnet publish -o package\cputil-osx-x64 -c Release -r osx-x64 \ No newline at end of file diff --git a/CloudPRNTSDKSamples/readme.md b/CloudPRNTSDKSamples/readme.md index 2de243e..1b4047f 100644 --- a/CloudPRNTSDKSamples/readme.md +++ b/CloudPRNTSDKSamples/readme.md @@ -1,59 +1,61 @@ # 1. Overview -This package contains cputil Ver 1.1.0. +This package contains cputil Ver 1.1.2. cputil is intented to serve and a useful back-end tool to help with implementing CloudPRNT servers that are not .Net or .Net Core based. -cputil can be use on any platform supported by .Net Core 2.1 including: +cputil can be use on any platform supported by .NET 6.0 including: - Windows x86 and x64 - + cputil-win-x86_v110.zip / cputil-win-x64_v110.zip + + cputil-win-x86_v112.zip / cputil-win-x64_v112.zip - Linux x64 - + cputil-linux-x64_v110.tar.gz + + cputil-linux-x64_v112.tar.gz - Apple Mac OS (OSX) x64 (Except 10.15 or later) - + cputil-osx-x64_v110.tar.gz + + cputil-osx-x64_v112.tar.gz - Apple Mac OS (OSX) x64 (10.15 or later) - + cputil-osx-x64_v110.zip + + cputil-osx-x64_v112.zip - Linux Arm (Raspberry PI compatible) - + cputil-linux-arm_v110.tar.gz + + cputil-linux-arm_v112.tar.gz In all cases, it is possible to build a self contained package that can be run on the desired platform without the need for a .Net Framework or .Net Core installation. Please refer to SDK documents for details. -(https://www.star-m.jp/products/s_print/CloudPRNTSDK/Documentation/en/index.html) +(https://star-m.jp/products/s_print/sdk/StarCloudPRNT/manual/en/index.html) # 2. Contents ~~~ -cputil-_v110.zip(or .tar.gz) +cputil-_v112.zip(or .tar.gz) |- Readme_En.txt // Release Notes (English) |- Readme_Jp.txt // Release Notes (Japanese) |- SoftwareLicenseAgreement.pdf // Software License Agreement (English) |- SoftwareLicenseAgreement_Jp.pdf // Software License Agreement (Japanese) +|- SoftwareLicenseAgreementAppendix.pdf // Software License Agreement Appendix | +- cputil- - |- cputil(.exe) // cputil executable file + |- cputil(.exe) // cputil executable file ~~~ # 3. Scope -cputil can be use on any platform supported by .Net Core 2.1 including: +cputil can be use on any platform supported by .NET 6.0 including: - Windows x86 and x64 - + cputil-win-x86_v110.zip / cputil-win-x64_v110.zip + + cputil-win-x86_v112.zip / cputil-win-x64_v112.zip - Linux x64 - + cputil-linux-x64_v110.tar.gz + + cputil-linux-x64_v112.tar.gz - Apple Mac OS (OSX) x64 (Except 10.15 or later) - + cputil-osx-x64_v110.tar.gz + + cputil-osx-x64_v112.tar.gz - Apple Mac OS (OSX) x64 (10.15 or later) - + cputil-osx-x64_v110.zip + + cputil-osx-x64_v112.zip - Linux Arm (Raspberry PI compatible) - + cputil-linux-arm_v110.tar.gz + + cputil-linux-arm_v112.tar.gz Works with these CloudPRNT client printers: - mC-Print2 - mC-Print3 +- TSP100IV - TSP650II with IFBD-HI01X - TSP700II with IFBD-HI01X - TSP800II with IFBD-HI01X @@ -79,21 +81,21 @@ Please unzip/extract cputil-.zip(or .tar.gz) to any specified pat The below operation is to test this "Usage Example". Please open the terminal or command prompt on each PC and perform following command. - Windows - ~~~ - > cd \cputil-win-x64_v110\cputil-win-x64 + ~~~ console + > cd \cputil-win-x64_v112\cputil-win-x64 ~~~ or - ~~~ - > cd \cputil-win-x86_v110\cputil-win-x86 + ~~~ console + > cd \cputil-win-x86_v112\cputil-win-x86 ~~~ - Linux - ~~~ + ~~~ console $ cd /cputil-linux-x64 ~~~ - macOS - ~~~ + ~~~ console $ cd /cputil-osx-x64 ~~~ @@ -105,25 +107,25 @@ Therefore just input "cputil" is enough when perform cputil command on terminal Star CloudPRNT devices will report their status in Star ASB format, as a string of 7 or more hexadecimal values. For Example: -~~~ +~~~ console > "23 86 00 00 00 00 00 00 00 00 00" ~~~ This is not easy to decode in all languages, and do cputil provides a method to convert this into JSON format data, e.g.: - Windows - ~~~ + ~~~ console > .\cputil.exe jsonstatus "23 86 00 00 00 00 00 00 00 00 00" ~~~ - Linux / macOS - ~~~ + ~~~ console $ ./cputil jsonstatus "23 86 00 00 00 00 00 00 00 00 00" ~~~ will generate the output: -~~~ +~~~ console > { > "Online": true, > "CoverOpen": false, @@ -144,7 +146,7 @@ will generate the output: ## Handling Print Job media formats -cputil can help with key parts of the CloudPRNT printing process. +cputil can help with key parts of the CloudPRNT printing process. A server can prepare a print job in a single input format, which may not be natively supported by the \cloudPRNT client device. The server can then use cputil to convert the job, as needed to a format that the CloudPRNT client does support. @@ -170,7 +172,7 @@ When a CloudPRNT compatible server has a print job ready for a particular client For example: -~~~ +~~~ console > { > "jobReady": true, > "mediaTypes": ["image/jpeg", "image/png"] @@ -182,18 +184,18 @@ At this point in the job printing negotiation, cputil can be used to prepare the For example, for a server that will use a PNG image as the initial print job source, use (In this sample, sourceimage.png is the name of the input file. Please prepare and put the file to directory same as cputil executable): - Windows - ~~~ + ~~~ console > .\cputil.exe mediatypes sourceimage.png ~~~ - Linux / macOS - ~~~ + ~~~ console $ ./cputil mediatypes sourceimage.png ~~~ which will generate the JSON ready output: -~~~ +~~~ console > ["image/png","image/jpeg","application/vnd.star.raster","application/vnd.star.line","application/vnd.star.starprnt","application/vnd.star.starprntcore"] ~~~ @@ -213,13 +215,13 @@ For example, if a server has prepared a print job as png data, and the client re - Windows - ~~~ + ~~~ console > .\cputil.exe decode "application/vnd.star.starprnt" sourceimage.png outputdata.bin ~~~ - Linux / macOS - ~~~ + ~~~ console $ ./cputil decode "application/vnd.star.starprnt" sourceimage.png outputdata.bin ~~~ @@ -228,12 +230,14 @@ Which will convert the png input file into printer command data stored in "outpu And also, if a server has prepared a print job as star document markup text data(filename extension is ".stm"), and the client requests it as StarPRNT printer command data (application/vnd.star.starprnt) then cputil can be used: - Windows - ~~~ + + ~~~ console > .\cputil.exe decode application/vnd.star.starprnt starmarkup.stm outputdata.bin ~~~ - Linux / macOS - ~~~ + + ~~~ console $ ./cputil decode application/vnd.star.starprnt starmarkup.stm outputdata.bin ~~~ @@ -266,25 +270,26 @@ For example, to prepare print data as StarPRNT commands for a 2inch printer from - Windows + For 2inch printer(mC-Print2): - ~~~ + ~~~ console > .\cputil.exe thermal2 dither scale-to-fit decode "application/vnd.star.starprnt" sourceimage.png outputdata_2.bin ~~~ + For 3inch printer(mC-Print3): - ~~~ + ~~~ console > .\cputil.exe thermal3 dither scale-to-fit decode "application/vnd.star.starprnt" sourceimage.png outputdata_3.bin ~~~ - Linux / macOS + For 2inch printer(mC-Print2): - ~~~ + ~~~ console $ ./cputil thermal2 dither scale-to-fit decode "application/vnd.star.starprnt" sourceimage.png outputdata_2.bin ~~~ + For 3inch printer(mC-Print3): - ~~~ + + ~~~ console $ ./cputil thermal3 dither scale-to-fit decode "application/vnd.star.starprnt" sourceimage.png outputdata_3.bin ~~~ @@ -313,23 +318,27 @@ For example, to prepare print data as StarPRNT commands for a 2 inch printer fro - Windows + For 2inch printer(mC-Print2): - ~~~ + + ~~~ console > .\cputil.exe thermal2 scale-to-fit drawer-end decode "application/vnd.star.starprnt" sourceimage.png outputdata_2.bin ~~~ + For 3inch printer(mC-Print3): - ~~~ + + ~~~ console > .\cputil.exe thermal3 scale-to-fit buzzer-end 1 decode "application/vnd.star.starprnt" sourceimage.png outputdata_3.bin ~~~ - Linux / macOS + For 2inch printer(mC-Print2): - ~~~ + + ~~~ console $ ./cputil thermal2 scale-to-fit drawer-end decode "application/vnd.star.starprnt" sourceimage.png outputdata_2.bin ~~~ + For 3inch printer(mC-Print3): - ~~~ + + ~~~ console $ ./cputil thermal3 scale-to-fit buzzer-end 1 decode "application/vnd.star.starprnt" sourceimage.png outputdata_3.bin ~~~ @@ -357,23 +366,27 @@ For example, to prepare print data as StarPRNT commands for a 2 inch printer fro - Windows + For 2inch printer(mC-Print2): - ~~~ + + ~~~ console > .\cputil.exe thermal2 scale-to-fit presentstatus-valid holdprint-invalid decode application/vnd.star.starprnt sourceimage.png outputdata_2.bin ~~~ + For 3inch printer(mC-Print3): - ~~~ + + ~~~ console > .\cputil.exe thermal3 scale-to-fit presentstatus-valid holdprint-invalid decode application/vnd.star.starprnt sourceimage.png outputdata_3.bin ~~~ - Linux / macOS + For 2inch printer(mC-Print2): - ~~~ + + ~~~ console $ ./cputil thermal2 scale-to-fit presentstatus-valid holdprint-invalid decode "application/vnd.star.starprnt" sourceimage.png outputdata_2.bin ~~~ + For 3inch printer(mC-Print3): - ~~~ + + ~~~ console $ ./cputil thermal3 scale-to-fit presentstatus-valid holdprint-invalid decode "application/vnd.star.starprnt" sourceimage.png outputdata_3.bin ~~~ @@ -386,7 +399,7 @@ Alternatively, ensure that your CloudPRNT service uses device command print job # 5. Limitation -1. Word wrapping / column command for starmarkup features with Unicode character are only supported by mC-Print2 / mC-Print3 / TSP650II. +1. Word wrapping / column command for starmarkup features with Unicode character are only supported by mC-Print2 / mC-Print3 / TSP650II. # 6. OSS Licenses @@ -406,6 +419,17 @@ Copyright 2019 Star Micronics Co., Ltd. All rights reserved. # 8. Release History +- Ver 1.1.2 (2022/04/28) + + Update the SixLabors.ImageSharp library from V1.0.2 to V1.0.4 to support .NET 6.0 environment. + + Update the Newtonsoft.Json library from V12.0.3 to V13.0.1. + + Update the .NET framework from .NET Core 3.1 to .NET 6.0. + +- Ver 1.1.1 (2021/01/18) + + Update the SixLabors.ImageSharp library from V100-beta007 to V1.0.2. + + Update the .NET Core framework from 2.1 to 3.1. + + Improve the long data URLs length limit in Markup. + + Support for the sbcs option in cputil for models that do not support utf8 code pages. + - Ver.1.1.0 (2020/06/17) + Support the command option of drawer for controlling CashDrawer. + Support the command option of buzzer for controlling Buzzer. diff --git a/ExampleServers/php_queue/cloudprnt-setting.json b/ExampleServers/php_queue/cloudprnt-setting.json new file mode 100755 index 0000000..7c21d3d --- /dev/null +++ b/ExampleServers/php_queue/cloudprnt-setting.json @@ -0,0 +1,5 @@ +{ + "title":"star_cloudprnt_server_setting", + "version":"1.0.0", + "serverSupportProtocol":["HTTP"] +} \ No newline at end of file diff --git a/ExampleServers/php_queue/cloudprnt-setting_Sample/cloudprnt-setting_http.json b/ExampleServers/php_queue/cloudprnt-setting_Sample/cloudprnt-setting_http.json new file mode 100755 index 0000000..7c21d3d --- /dev/null +++ b/ExampleServers/php_queue/cloudprnt-setting_Sample/cloudprnt-setting_http.json @@ -0,0 +1,5 @@ +{ + "title":"star_cloudprnt_server_setting", + "version":"1.0.0", + "serverSupportProtocol":["HTTP"] +} \ No newline at end of file diff --git a/ExampleServers/php_queue/cloudprnt-setting_Sample/cloudprnt-setting_mqtt.json b/ExampleServers/php_queue/cloudprnt-setting_Sample/cloudprnt-setting_mqtt.json new file mode 100755 index 0000000..019e2ec --- /dev/null +++ b/ExampleServers/php_queue/cloudprnt-setting_Sample/cloudprnt-setting_mqtt.json @@ -0,0 +1,17 @@ +{ + "title":"star_cloudprnt_server_setting", + "version":"1.0.0", + "serverSupportProtocol":["HTTP", "MQTT"], + "settingForMQTT":{ + "useTriggerPOST":false, + "mqttConnectionSetting":{ + "hostName":"172.16.212.228", + "portNumber":1883, + "useTls" : false, + "authenticationSetting":{ + "username":"user", + "password":"pass" + } + } + } +} \ No newline at end of file diff --git a/ExampleServers/php_queue/cloudprnt-setting_Sample/cloudprnt-setting_mqtt_triggerpost.json b/ExampleServers/php_queue/cloudprnt-setting_Sample/cloudprnt-setting_mqtt_triggerpost.json new file mode 100755 index 0000000..8f44c9a --- /dev/null +++ b/ExampleServers/php_queue/cloudprnt-setting_Sample/cloudprnt-setting_mqtt_triggerpost.json @@ -0,0 +1,17 @@ +{ + "title":"star_cloudprnt_server_setting", + "version":"1.0.0", + "serverSupportProtocol":["HTTP", "MQTT"], + "settingForMQTT":{ + "useTriggerPOST":true, + "mqttConnectionSetting":{ + "hostName":"172.16.212.228", + "portNumber":1883, + "useTls" : false, + "authenticationSetting":{ + "username":"user", + "password":"pass" + } + } + } +} \ No newline at end of file diff --git a/ExampleServers/php_queue/cloudprnt.php b/ExampleServers/php_queue/cloudprnt.php index 2b1d9b9..2ab7e66 100755 --- a/ExampleServers/php_queue/cloudprnt.php +++ b/ExampleServers/php_queue/cloudprnt.php @@ -1,117 +1,13 @@ busyTimeout(1000); - $options = $options." scale-to-fit dither "; - - system($cputilpath." ".$options." decode \"".$outputFormat."\" \"".$inputFile."\" \"".$outputFile."\"", $retval); -} - -/* - Create the print job using Star Markup -*/ -function renderMarkupJob($filename, $position, $queue, $design) { - $file = fopen($filename, 'w+'); - - if ($file != FALSE) { - fwrite($file, "[align: centre]"); - - if (isset($design['Logo'])) { - fwrite($file, "[image: url ".$design['Logo']."; width 100%]\n"); - } - - if (isset($design['Header'])) { - fwrite($file, $design['Header']."\n"); - } - - fwrite($file, "[align: centre]"); - fwrite($file, "[mag: w 4; h 4]".$position."[mag]\n"); - - if (isset($design['Footer'])) { - fwrite($file, $design['Footer']."\n"); - } - - if (isset($design['Coupon'])) { - fwrite($file, "[image: url ".$design['Coupon']."; width 100%]\n"); - } - - fwrite($file, "[cut]"); - - fclose($file); - } -} - -/* - Read the formatting parameters for the specified queue id from the database (logo, header, footer, coupon...) - and return as a table -*/ -function getQueuePrintParameters($db, $queue) { - $qfields = array(); - $qfields['Header'] = ""; - $qfields['Footer'] = ""; - $qfields['Logo'] = ""; - $qfields['Coupon'] = ""; - - $results = $db->query("SELECT Header, Footer, Logo, Coupon FROM Queues WHERE id = '" .$queue."'"); - - if (isset($results)) { - $row = $results->fetchArray(); // fetch next row - - if (isset($row) && !empty($row)) { - $qfields['Header'] = $row['header']; - $qfields['Footer'] = $row['footer']; - $qfields['Logo'] = $row['logo']; - $qfields['Coupon'] = $row['coupon']; - } else { - // error message - } - } - - return $qfields; -} function handleCloudPRNTGetJob($db) { $content_type = $_GET['type']; // determine the media type that the cloudPRNT device is requesting @@ -141,23 +37,6 @@ function handleCloudPRNTGetJob($db) { unlink($outputfile); } -/* - Get a list of supported input types from "cputil" for a given input type -*/ -function getCPSupportedOutputs($input) { - global $cputilpath; - $file = popen($cputilpath." mediatypes-mime \"text/vnd.star.markup\"", "r"); - - if ($file != FALSE) { - $output = fread($file, 8192); - - pclose($file); - return json_decode($output); - } - - return ""; -} - /* Determine whether printing is required for a particular printer, buy checking it's 'Printing' field which will be set to the position number to be printer when a job is required. @@ -179,6 +58,35 @@ function getDevicePrintingRequired($db, $mac) { } } +/* + Read the formatting parameters for the specified queue id from the database (logo, header, footer, coupon...) + and return as a table +*/ +function getQueuePrintParameters($db, $queue) { + $qfields = array(); + $qfields['Header'] = ""; + $qfields['Footer'] = ""; + $qfields['Logo'] = ""; + $qfields['Coupon'] = ""; + + $results = $db->query("SELECT Header, Footer, Logo, Coupon FROM Queues WHERE id = '" .$queue."'"); + + if (isset($results)) { + $row = $results->fetchArray(); // fetch next row + + if (isset($row) && !empty($row)) { + $qfields['Header'] = $row['header']; + $qfields['Footer'] = $row['footer']; + $qfields['Logo'] = $row['logo']; + $qfields['Coupon'] = $row['coupon']; + } else { + // error message + } + } + + return $qfields; +} + /* Query the database and return the stored print width for the device. This will be used by cputil for correctly formatting the print job. @@ -220,14 +128,18 @@ function setDeviceInfo($db, $mac, $width, $clientType, $clientVer) { the specified mac address. */ function setDeviceStatus($db, $mac, $status) { - $tstamp = time(); // Store time simply as number of seconds since 1970-01-01 00:00:00+0000 (UTC) - $affected = $db->query("UPDATE Devices SET 'Status' = '".$status."', 'LastPoll' = '".$tstamp."' WHERE DeviceMac = '".$mac."';"); - if (empty($affected)) { + // Confirm device is resgitered. + $exists = $db->querySingle("SELECT DeviceMac FROM Devices WHERE DeviceMac = '".$mac."'"); + + if (!isset($exists)) { return false; } - return true; + $tstamp = time(); // Store time simply as number of seconds since 1970-01-01 00:00:00+0000 (UTC) + $affected = $db->query("UPDATE Devices SET 'Status' = '".$status."', 'LastPoll' = '".$tstamp."' WHERE DeviceMac = '".$mac."';"); + + return true; } function handleCloudPRNTPoll($db) { @@ -333,18 +245,28 @@ function handleCloudPRNTDelete($db) { if (!isset($db) || empty($db)) { http_response_code(500); -} elseif ($_SERVER['REQUEST_METHOD'] === "GET") { - if(strpos($_SERVER['QUERY_STRING'], "&delete") !== false) { // if server set "deleteMethod":"GET" in POST response +} else { + if (isset($argc, $argv)) { + if ($argv[1] == "MQTT") { // Received MQTT Message (CloudPRNT MQTT Protocol) + $mqtt_components = explode(" ", $argv[2], 2); // output of "mosquitto_pub -v". topic and payload. + $mqtt_topic = $mqtt_components[0]; + $mqtt_payload = $mqtt_components[1]; + + handleReceivedMqttMessage($db, $mqtt_topic, $mqtt_payload); + } + } elseif ($_SERVER['REQUEST_METHOD'] === "GET") { // Received HTTP Request + if(strpos($_SERVER['QUERY_STRING'], "&delete") !== false) { // if server set "deleteMethod":"GET" in POST response + handleCloudPRNTDelete($db); + } else { // Request a content of print job + handleCloudPRNTGetJob($db); + } + } elseif ($_SERVER['REQUEST_METHOD'] === "POST") { + handleCloudPRNTPoll($db); + } elseif ($_SERVER['REQUEST_METHOD'] === "DELETE") { handleCloudPRNTDelete($db); - } else { // Request a content of print job - handleCloudPRNTGetJob($db); + } else { + http_response_code(405); } -} elseif ($_SERVER['REQUEST_METHOD'] === "POST") { - handleCloudPRNTPoll($db); -} elseif ($_SERVER['REQUEST_METHOD'] === "DELETE") { - handleCloudPRNTDelete($db); -} else { - http_response_code(405); } $db->close(); diff --git a/ExampleServers/php_queue/cpphp.css b/ExampleServers/php_queue/cpphp.css index e7d8f4e..1ab1385 100755 --- a/ExampleServers/php_queue/cpphp.css +++ b/ExampleServers/php_queue/cpphp.css @@ -21,6 +21,7 @@ p { background-color: lightslategrey; border-radius: 10pt; padding: 40pt; + margin : 20pt ; cursor: pointer; font-family: Verdana, Geneva, Tahoma, sans-serif; font-size: xx-large; diff --git a/ExampleServers/php_queue/cputil.php b/ExampleServers/php_queue/cputil.php new file mode 100755 index 0000000..976f3c8 --- /dev/null +++ b/ExampleServers/php_queue/cputil.php @@ -0,0 +1,102 @@ + diff --git a/ExampleServers/php_queue/devices.php b/ExampleServers/php_queue/devices.php index fe85898..b4251c0 100755 --- a/ExampleServers/php_queue/devices.php +++ b/ExampleServers/php_queue/devices.php @@ -19,9 +19,17 @@ function delDevice($db, $mac) { } } +function resetDevice($db, $mac) { + $affected = $db->query("UPDATE Devices SET 'Printing' = 0 WHERE DeviceMac = '".$mac."';"); + + if (!isset($affected)) { + http_response_code(500); + } +} + function listDevices($db) { global $deviceTimeout; - $results = $db->query("SELECT DeviceMac, Status, QueueID, Queues.name, ClientType, ClientVersion, LastPoll FROM Devices INNER JOIN Queues ON Queues.id = Devices.QueueID"); + $results = $db->query("SELECT DeviceMac, Status, QueueID, Queues.name, Printing, ClientType, ClientVersion, LastPoll FROM Devices INNER JOIN Queues ON Queues.id = Devices.QueueID"); $rdata = array(); $count = 0; @@ -39,14 +47,18 @@ function listDevices($db) { $rdata[$count] = array("mac" => strval($row['DeviceMac'])); - if (intval($secondsElapsed) < intval($deviceTimeout)) { + if ($lpt == 0) { + $rdata[$count] += array("status" => "Not Connected Yet."); + } + else if (intval($secondsElapsed) < intval($deviceTimeout)) { $rdata[$count] += array("status" => strval($row['Status'])); } else { - $rdata[$count] += array("status" => "Connection Lost"); + $rdata[$count] += array("status" => "Last status was more than 10 seconds ago."); } $rdata[$count] += array("queueId" => strval($row['QueueID'])); $rdata[$count] += array("queueName" => strval($row['name'])); + $rdata[$count] += array("printing" => strval($row['Printing'])); $rdata[$count] += array("clientType" => strval($row['ClientType'])); $rdata[$count] += array("clientVersion" => strval($row['ClientVersion'])); $rdata[$count] += array("lastConnection" => strval($row['LastPoll'])); @@ -65,6 +77,7 @@ function listDevices($db) { function handleGETRequest() { $dbname = "simplequeue.sqlite"; // database file name $db = new SQLite3($dbname); + $db->busyTimeout(1000); if (!empty($_GET['new'])) { $new = $_GET['new']; @@ -78,6 +91,10 @@ function handleGETRequest() { $del = $_GET['del']; } + if (!empty($_GET['reset'])) { + $reset = $_GET['reset']; + } + if (!isset($db) || empty($db)) { http_response_code(500); return; @@ -87,6 +104,8 @@ function handleGETRequest() { addDevice($db, $new, $queue); } elseif (isset($del)) { delDevice($db, $del); + } elseif (isset($reset)) { + resetDevice($db, $reset); } else { listDevices($db); } diff --git a/ExampleServers/php_queue/js/management.js b/ExampleServers/php_queue/js/management.js index 226fc7f..6300568 100755 --- a/ExampleServers/php_queue/js/management.js +++ b/ExampleServers/php_queue/js/management.js @@ -22,8 +22,8 @@ function UpdateDeviceTable() { .done(function(data) { var table = "" - table += ""; - table += ''; + table += ""; + table += ''; for(var i = 0; i < data.length; i++) { @@ -32,16 +32,24 @@ function UpdateDeviceTable() { var lastConnect = new Date(1970, 0, 1); lastConnect.setSeconds(device.lastConnection); + var printing = "-"; + if (device.printing > 0) { + printing = device.printing + } + table += ""; table += ""; table += ""; table += ""; + table += ""; table += ""; table += ""; table += ""; table += "" @@ -105,12 +113,28 @@ function NewDevice() $.get("devices.php?new=" + newMac + "&queue=" + newQ); } +function getStatus(mac) +{ + $.get("management.php?mac=" + mac + "&method=request-client-status") + .done(function() { + window.alert("MQTT message has been published successfully."); + }) + .fail(function() { + window.alert("Failed to publish a MQTT message."); + } ) +} + function delDevice(mac) { if(confirm("Remove Device, are you sure?")) $.get("devices.php?del=" + mac); } +function resetDevice(mac) +{ + $.get("devices.php?reset=" + mac); +} + function NewQueue() { var newQ = prompt("Please enter the new queue name", ""); diff --git a/ExampleServers/php_queue/management.php b/ExampleServers/php_queue/management.php new file mode 100755 index 0000000..b4cd9d3 --- /dev/null +++ b/ExampleServers/php_queue/management.php @@ -0,0 +1,33 @@ + diff --git a/ExampleServers/php_queue/mqtt_handle_received_message.php b/ExampleServers/php_queue/mqtt_handle_received_message.php new file mode 100755 index 0000000..5333165 --- /dev/null +++ b/ExampleServers/php_queue/mqtt_handle_received_message.php @@ -0,0 +1,105 @@ + "PageInfo", "options" => ""); + $payload['clientAction'][1] = array("request" => "ClientType", "options" => ""); + $payload['clientAction'][2] = array("request" => "ClientVersion", "options" => ""); + + $result = publishMqttMessage($topic, json_encode($payload)); + } else { + // No client action is needed. + } + } +} + +/* + Handle MQTT print-result +*/ +function handlePrintResult($db, $parsed_payload) { + $clearJobFromDB = true; + + $statusCode = urldecode($parsed_payload['statusCode']); + $headercode = substr($statusCode, 0, 1); + + if ($headercode != "2") { + // error message + } + + if ($clearJobFromDB) { + setCompleteJob($db, $parsed_payload['printerMAC']); + } +} + +?> diff --git a/ExampleServers/php_queue/mqtt_publish.php b/ExampleServers/php_queue/mqtt_publish.php new file mode 100755 index 0000000..a6574ab --- /dev/null +++ b/ExampleServers/php_queue/mqtt_publish.php @@ -0,0 +1,139 @@ + "full", "feed" => true); + } + + } else { + // ignore + } + + $result = publishMqttMessage($topic, json_encode($payload, JSON_UNESCAPED_SLASHES)); + + if ($result) { + http_response_code(200); + } else { + http_response_code(400); + } + + return $result; +} + +/* + Publish MQTT Message using mosquitto_pub +*/ +function publishMqttMessage($topic, $payload) { + + // Load settings for MQTT. + $parsed = loadParsedServerSettingsJson(); + + if (isset($parsed) && !empty($parsed)) { + $hostName = $parsed['settingForMQTT']['mqttConnectionSetting']['hostName']; + $portNumber = $parsed['settingForMQTT']['mqttConnectionSetting']['portNumber']; + + $username = $parsed['settingForMQTT']['mqttConnectionSetting']['authenticationSetting']['username']; + $password = $parsed['settingForMQTT']['mqttConnectionSetting']['authenticationSetting']['password']; + + // escape double quotes to use mosquitto_pub. + $payload = str_replace("\"", "\\\"", $payload); + + // Remove Newline from payload to use mosquitto_pub. + //$payload = str_replace(array("\r\n", "\r", "\n"), "", $payload); + + if (isset($username, $password)) { + $command = "mosquitto_pub -h {$hostName} -p {$portNumber} -u {$username} -P {$password} -t {$topic} -m \"{$payload}\" -V 311"; + } else { + $command = "mosquitto_pub -h {$hostName} -p {$portNumber} -t {$topic} -m \"{$payload}\" -V 311"; + } + + exec($command, $output, $result); + + if ($result != 0) { + // mosquitto_pub failed + return false; + } + return true; + } else { + return false; + } +} + +/* + Load cloudprnt-setting.json +*/ +function loadParsedServerSettingsJson() { + if (substr(PHP_OS,0,3) == 'WIN') { + if (file_exists(dirname(__FILE__).'\cloudprnt-setting.json')) { + $serverSettingJson = file_get_contents(dirname(__FILE__).'\cloudprnt-setting.json'); + } + } else { + if (file_exists(dirname(__FILE__).'/cloudprnt-setting.json')) { + $serverSettingJson = file_get_contents(dirname(__FILE__).'/cloudprnt-setting.json'); + } + } + + if (isset($serverSettingJson) && !empty($serverSettingJson)) { + $parsed = json_decode($serverSettingJson, true); + } + + return $parsed; +} + +?> diff --git a/ExampleServers/php_queue/mqtt_subscribe.ps1 b/ExampleServers/php_queue/mqtt_subscribe.ps1 new file mode 100755 index 0000000..499b287 --- /dev/null +++ b/ExampleServers/php_queue/mqtt_subscribe.ps1 @@ -0,0 +1,14 @@ +echo "Start MQTT Subscribe." + +& 'C:\Program Files\mosquitto\mosquitto_sub.exe' -h 172.16.212.228 -p 1883 -u user -P pass -t star/cloudprnt/to-server/# -v -V 311 | ForEach-Object { +echo $_ + +& 'C:\php\php.exe' C:\Apache\Apache24\htdocs\php_queue\cloudprnt.php "MQTT" $_.Replace('"', '\"') +} + +echo "End MQTT Subscribe." + + +# Subscribe using mosquitto_sub.exe. +# Please specify the host address etc. to connect to the broker. +# Start a PHP program every time an MQTT message is received. diff --git a/ExampleServers/php_queue/mqtt_subscribe.sh b/ExampleServers/php_queue/mqtt_subscribe.sh new file mode 100755 index 0000000..18fac4f --- /dev/null +++ b/ExampleServers/php_queue/mqtt_subscribe.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +function callPHP() { + VAR=$1 + echo "${VAR//'"'/'\"'}" + php /var/www/html/php_queue/cloudprnt.php "MQTT" "$1" +} + +export -f callPHP + +echo "Start MQTT Subscribe." + +mosquitto_sub -h 172.16.212.228 -p 1883 -u user -P pass -t star/cloudprnt/to-server/# -v -V 311 | xargs -d'\n' -I@ bash -c "callPHP '@'" + +echo "End MQTT Subscribe." + +# Subscribe using mosquitto_sub. +# Please specify the host address etc. to connect to the broker. +# Start a PHP program every time an MQTT message is received. diff --git a/ExampleServers/php_queue/print.html b/ExampleServers/php_queue/print.html index 7e81939..d432f83 100755 --- a/ExampleServers/php_queue/print.html +++ b/ExampleServers/php_queue/print.html @@ -10,7 +10,47 @@ var printer = urlParams.get('mac'); function PrintATicket() { - $.get("print.php?mac=" + printer ); + $.get("print.php?mac=" + printer ) + .done(function() { + window.alert("Successfully triggered print."); + }) + .fail(function() { + window.alert("An error has occurred."); + } ) + + } + + function PrintATicketTriggerPost() { + $.get("print.php?mac=" + printer + "&protocol=mqtt&method=request-post") + .done(function() { + window.alert("Successfully triggered print."); + }) + .fail(function() { + window.alert("An error has occurred."); + } ) + + } + + function PrintATicketPassUrl() { + $.get("print.php?mac=" + printer + "&protocol=mqtt&method=print-job&jobType=url") + .done(function() { + window.alert("Successfully triggered print."); + }) + .fail(function() { + window.alert("An error has occurred."); + } ) + + } + + function PrintATicketAllMqtt() { + $.get("print.php?mac=" + printer + "&protocol=mqtt&method=print-job&jobType=raw") + .done(function() { + window.alert("Successfully triggered print."); + }) + .fail(function() { + window.alert("An error has occurred."); + } ) + } @@ -20,7 +60,21 @@

Please take a ticket

- Print + Print (HTTP) +
+ +

To try "Print (MQTT)" below, a CloudPRNT Version MQTT compatible printer is required.

+ +
+ Print (MQTT : Trigger POST) +
+ +
+ Print (MQTT : Pass URL) +
+ +
+ Print (MQTT : Full MQTT)
diff --git a/ExampleServers/php_queue/print.php b/ExampleServers/php_queue/print.php index 32891b8..bdfbfa4 100755 --- a/ExampleServers/php_queue/print.php +++ b/ExampleServers/php_queue/print.php @@ -1,6 +1,8 @@ query("SELECT position FROM Queues WHERE id = '".$queue."'"); @@ -35,6 +37,17 @@ function triggerPrint($db, $mac, $queue) { return; } +/* + Clear a print job from the database, for the specified printer, but setting it's 'Position' field to 'null' +*/ +function setCompleteJob($db, $mac) { + $affected = $db->query("UPDATE Devices SET 'Printing' = 0 WHERE DeviceMac = '".$mac."';"); + + if (!isset($affected)) { + // error message + } +} + function getQueueIDAndPrintingState($db, $mac) { $results = $db->query("SELECT QueueID, Printing FROM Devices WHERE DeviceMac = '".$mac."'"); @@ -50,9 +63,12 @@ function getQueueIDAndPrintingState($db, $mac) { return array(NULL, NULL); } -function handleGETRequest() { +function handleGETRequestForPrint() { $dbname = "simplequeue.sqlite"; // database file name $db = new SQLite3($dbname); + $db->busyTimeout(1000); + + $isPrinting = false; if (!empty($_GET['mac'])) { $mac = $_GET['mac']; @@ -78,18 +94,82 @@ function handleGETRequest() { if ((isset($printing)) && ($printing > 0)) { - http_response_code(200); - return; // Don't issue a ticket if one is currently printing + $isPrinting = true; } - $pos = triggerPrint($db, $mac, $queue); + // check CloudPRNT Protocol. + if (!empty($_GET['protocol'])) { + $protocol = $_GET['protocol']; + + if ($protocol === "mqtt") { + // for CloudPRNT Protocol Version MQTT + + if (!empty($_GET['method'])) { + $method = $_GET['method']; + } + + if (!$isPrinting){ + $pos = triggerPrint($db, $mac, $queue); + } + + if ($method === "request-post") { + // Trigger POST : request the printer to perform POST request + $result = handleGETRequestForPublishMessage($mac, $method); + + if (!$result) { + // Failed to publish MQTT message + setCompleteJob($db, $_GET['mac']); + } + } + else if ($method === "print-job") { + + if (!empty($_GET['jobType'])) { + $jobType = $_GET['jobType']; + } + + if($jobType === "url") { + // Pass URL + $result = handleGETRequestForPublishMessage($mac, $method, $jobType); + + if (!$result) { + // Failed to publish MQTT message + setCompleteJob($db, $_GET['mac']); + } + + } else { // $jobType === "raw" + // Full MQTT + $result = handleGETRequestForPublishMessage($mac, $method, $jobType); + + if (!$result) { + // Failed to publish MQTT message + setCompleteJob($db, $_GET['mac']); + } + } + + + } else { + http_response_code(405); + } + } else { + http_response_code(405); + } + } else { + // for CloudPRNT Protocol Version HTTP + if ($isPrinting) { + http_response_code(200); + return; // Don't issue a ticket if one is currently printing + } else { + $pos = triggerPrint($db, $mac, $queue); + } + } $db->close(); } if ($_SERVER['REQUEST_METHOD'] === "GET") { - handleGETRequest(); + handleGETRequestForPrint(); } else { http_response_code(405); } + ?> diff --git a/ExampleServers/php_queue/queues.php b/ExampleServers/php_queue/queues.php index fa4ff18..7d8881b 100755 --- a/ExampleServers/php_queue/queues.php +++ b/ExampleServers/php_queue/queues.php @@ -48,6 +48,8 @@ function listQueues($db) { function handleGETRequest() { $dbname = "simplequeue.sqlite"; // database file name $db = new SQLite3($dbname); + $db->busyTimeout(1000); + if (!empty($_GET['new'])) { $new = $_GET['new']; } diff --git a/ExampleServers/readme.md b/ExampleServers/readme.md index c3080bd..1a0a3a1 100644 --- a/ExampleServers/readme.md +++ b/ExampleServers/readme.md @@ -10,29 +10,33 @@ For printing, all print jobs are created using the Star Document Markup language This allows support of all CloudPRNT compatible printers, regardless of command emulation or print width. Please refer to SDK documents for CloudPRNT / Star Document Markup language / cputil details. -(https://www.star-m.jp/products/s_print/CloudPRNTSDK/Documentation/en/index.html) +(https://star-m.jp/products/s_print/sdk/StarCloudPRNT/manual/en/index.html) # 2. Contents ~~~ -php_queue_v110 -|- Readme_En.txt // Release Notes (English) -|- Readme_Jp.txt // Release Notes (Japanese) -|- SoftwareLicenseAgreement.pdf // Software License Agreement (English) -|- SoftwareLicenseAgreement_Jp.pdf // Software License Agreement (Japanese) -| -+- php_queue - |- cloudprnt.php // Sample CloudPRNT Queue system handler including a using of cputil - |- cpphp.css // Style sheet for mangament.html / print.html - |- devices.php // Sample for querying the database, managing queue of device information - |- management.html // Management page for regsiter/query printer and queue for print job - |- print.html // Simple print button web page for registered device - |- print.php // Sample for querying the database, configuring and triggering jobs - |- queues.php // Sample for querying the database, managing queue of job data information - |- simplequeue.sqlite // Database file used by cloudprnt.php devices.php / print.php / queues.php - +- js - |- jquery-3.3.1.min.js // jquery 3.3.1 JavaScript library - +- management.js // JavaScript for updating a information of management.html +php_queue +|- cloudprnt.php // Sample CloudPRNT Queue system handler including a using of CPUtil +|- cpphp.css // Style sheet for mangament.html / print.html +|- devices.php // Sample for querying the database, managing queue of device information +|- management.html // Management page for regsiter/query printer and queue for print job +|- print.html // Simple print button web page for registered device +|- print.php // Sample for querying the database, configuring and triggering jobs +|- queues.php // Sample for querying the database, managing queue of job data information +|- simplequeue.sqlite // Database file used by cloudprnt.php devices.php / print.php / queues.php +|- cloudprnt-setting.json // (CloudPRNT Version MQTT) JSON data that responds to a "Server setting information request" from a printer +|- management.php // (CloudPRNT Version MQTT) Sample for triggering publish MQTT messages to printers on the Management page +|- mqtt_handle_received_message.php // (CloudPRNT Version MQTT) Sample for handling messages published from a printer to CloudPRNT server +|- mqtt_publish.php // (CloudPRNT Version MQTT) Sample for creating and publishing MQTT messages for printers +|- mqtt_subscribe.ps1 // (CloudPRNT Version MQTT) For Windows : Sample for subscribing to MQTT messages for CloudPRNT servers and executing cloudprnt.php with the received messages as arguments +|- mqtt_subscribe.sh // (CloudPRNT Version MQTT) For Linux Ubuntu : Sample for subscribing to MQTT messages for CloudPRNT servers and executing cloudprnt.php with the received messages as arguments ++- js +| |- jquery-3.3.1.min.js // jquery 3.3.1 JavaScript library +| +- management.js // JavaScript for updating a information of management.html ++- cloudprnt-setting_Sample // (CloudPRNT Version MQTT) Sample response JSON data for "Server setting information request" from a printer + |-cloudprnt-setting_http.json // For CloudPRNT Version HTTP Setting Sample + |-cloudprnt-setting_mqtt_triggerpost.json // For CloudPRNT Version MQTT (Trigger POST) Setting Sample + +-cloudprnt-setting_mqtt.json // For CloudPRNT Version MQTT (Full MQTT / Pass URL) Setting Sample ~~~ # 3. Scope @@ -43,6 +47,9 @@ Works with these CloudPRNT client printers: - mC-Print2 - mC-Print3 +- TSP100IV +- TSP100IV SK +- mC-Label3 - TSP650II with IFBD-HI01X - TSP700II with IFBD-HI01X - TSP800II with IFBD-HI01X @@ -51,7 +58,10 @@ Works with these CloudPRNT client printers: Please refer to each CloudPRNT client printer for details. You can check the manual from Star web site. -(https://www.star-m.jp/products/s_print/CloudPRNTSDK/Documentation/en/developerguide/introduction.html) +(https://www.star-m.jp/products/s_print/sdk/StarCloudPRNT/manual/en/index.html)
+ +Please refer to the manual for details of CloudPRNT Version MQTT compatible printers. + (https://www.star-m.jp/products/s_print/sdk/StarCloudPRNT/manual/en/index.html#compatiblePrinters) # 4. Usage @@ -60,7 +70,7 @@ This example project can be work after hosting by server including PHP and SQLit It can be test by access to `http:///management.html` Please refer to SDK documents for details. -(https://www.star-m.jp/products/s_print/CloudPRNTSDK/Documentation/en/articles/sampleservers/php_queue.html) +(https://www.star-m.jp/products/s_print/sdk/StarCloudPRNT/manual/en/test.html) # 5. Copyright @@ -70,6 +80,8 @@ Copyright 2019 Star Micronics Co., Ltd. All rights reserved. # 6. Release History +- Ver.2.0.0 (2023/12/22) + + Support CloudPRNT Version MQTT - Ver.1.1.0 (2020/06/17) + Modified to accept the capital input when register the printer MAC address at management.html + Add TSP650IISK printer model diff --git a/LICENSE b/LICENSE index ad01769..bd0c207 100644 --- a/LICENSE +++ b/LICENSE @@ -1,35 +1,119 @@ -Software License Agreement - -This Agreement made and entered into by and between you and Star Micronics Co., Ltd. (hereinafter referred to as "Star") stipulates the terms and conditions pertaining to the licensing of the software. Please read this Software License Agreement ("Agreement") carefully before installing or using the software and accompanying data (hereinafter referred to as "the Software"). By installing the Software, you are agreeing to be bound by this Agreement. If you do not agree to the terms of this Agreement, you are not entitled to install the Software. References to "Software" in this Agreement include any accompanying documentation furnished by Star. - -1. Permitted License Uses -During the term of this Agreement, Star grants to you a nonexclusive, non-transferable license to use the Software for your own use subject to the terms and conditions of this Agreement. Except for this limited license, Star reserves all other rights in the Software. The rights granted herein are limited to Star's intellectual property rights in the Software. Only for the purpose of using a Star product, you may install the Software on a computer that is directly or via a local area network connected to the Star product. - -2. Restrictions on Permitted License Uses -You may not reverse engineer, disassemble, or decompile with regard to the Software or otherwise attempt to discover the trade secrets in the Software. In addition, you may not copy, reproduce, alter, modify or create derivative works of the Software or any part thereof. Notwithstanding the provision above, you may analyze, copy, or alter the binary data (object code) of the part of source code disclosed out of the Software. You may not sublicense, transfer, rent, lease, or redistribute the Software to a third party. Star is not obligated to provide any maintenance, technical or other support for the Software. You may use the Software only with a Star product and you are not permitted to use the Software for any product other than a Star product. - -3. Intellectual Property Rights -Copyrights, patents and any other intellectual property rights in the Software shall belong to Star or Star's licensors. This is a license, not a sale. - -4. Termination -This Agreement is effective until terminated. Your rights under this Agreement will terminate automatically without notice from Star if you fail to comply with any term(s) of this Agreement. Upon the termination of this Agreement, you shall cease all use of the Software and destroy all copies, full or partial, of the Software. - -5. Disclaimer of Warranties -You expressly acknowledge and agree that use of the Software is at your sole risk and that the entire risk as to satisfactory quality, performance, accuracy and efforts is with you. The Software is provided "as is", with all faults and without warranty of any kind, and Star and Star's licensors hereby disclaim all warranties and conditions with respect to the Software, either express, implied or statutory, including, but not limited to, the implied warranties and/or conditions of merchantability, of satisfactory quality, of fitness for a particular purpose, of accuracy, of quiet enjoyment, and non-infringement of third party rights. Star does not warrant against interference with your enjoyment of the Software, that the functions contained in the Software will meet your requirements, that the operation of the Software will be uninterrupted or error-free, or that defects in the Software will be corrected. No oral or written information or advice given by Star or Star authorized representative shall create a warranty. Should the Software prove defective, you assume the entire cost of all necessary servicing, repair, or correction. - -6. Limitation of Liability -To the extent not prohibited by law, in no event shall Star be liable for personal injury, or any incidental, special, indirect or consequential damages whatsoever, including, without limitation, damages for loss of profits, loss of data, business interruption or any other commercial damages or losses, arising out of or related to your use or inability to use the Software, however caused, regardless of the theory of liability (contract, tort, or otherwise) and even if Star has been advised of the possibility of such damages. In any event, Star shall not be liable for any damages, in the aggregate, regardless of type or kind, whether in contract or tort, in excess of the actual license fees, if any, paid by you for the Software in the three (3) months immediately preceding the first event giving rise to liability. - -7. Governing Law and Severability -This Agreement will be governed by and construed in accordance with the laws of Japan. If for any reason a court of competent jurisdiction finds any provision, or portion thereof, to be unenforceable, the remainder of this Agreement shall continue in full force and effect. - -8. Third-party Software -If the whole or part of the Software includes any third-party software or intellectual property right including, but not limited to, open source software (hereinafter referred to as the "Third-party Software"), you shall comply with the terms and conditions of the license granted by the third party related to your use of the Third-party Software. In no event shall any of the provisions of this Agreement be construed as a limitation on the right of the third party to enforce each and every terms and conditions of the license. In no event shall Star be liable for any limitation on the use of the Software, which might be imposed by enforcement of the license by the third party. If the Software includes the Third-party Software, you will find the particulars thereof including the licensing conditions in the "SoftwareLicenseAgreementAppendix.pdf". All Third-party Software is provided as-is, with all faults and without warranties of any kind. - -9. Compensation for damages -If you fail to comply with any term of this Agreement, Star has the right to terminate this Agreement and any other agreement made with you and claim compensation for damages suffered resulting from such termination. - -10. Amendment and Alteration -You should be aware that we may change this Agreement at any time. In the event of a change, we will inform you of the change and changed version of this Agreement by displaying it on StarÅfs website or by other appropriate means. Unless otherwise specified, the changed version of this Agreement shall become effective when displayed on StarÅfs website. -To read our latest Software License Agreement, please visit the following URL. -https://www.star-m.jp/wp-content/uploads/SoftwareLicenseAgreement_web.pdf +Software License Agreement + + +I.General Terms and Conditions + +This General License Agreement ("Agreement") made and entered into by and between you and Star Micronics Co., Ltd. and/or its subsidiaries (hereinafter collectively referred to as "Star") stipulates the terms and conditions pertaining to the licensing of the software (including all related documentation and accompanying data furnished by Star, hereinafter referred to as "the Software"). This Agreement does not apply to any software, firmware or cloud services that are separately licensed or provided pursuant to a separate agreement with Star. +If you are entering into this Agreement on behalf of a business or other legal entity, you represent that you have the authority to bind such entity to this Agreement, in which case the terms, “you“,or “your” shall refer to such entity. +Please read this Agreement carefully before installing or using the Software. By Clicking the “Agree” Button or by installing and using the Software, you +(a) acknowledge that you have read and understand this Agreement; +(b) represent that you are 18 years of age or older/of legal age to enter into a binding Agreement; and +(c) accept this Agreement and agree that you are legally bound by its terms. +If you do not agree to the terms of this Agreement, you are not entitled to install the Software. + + +1. Permitted License Uses +During the terms of this Agreement, Star grants you a nonexclusive, non-transferable license to: +(a) download, install and use a single copy of the Software +(i) for your own internal business operations on a single compatible device owned or otherwise controlled by you (hereinafter referred to as "Device") strictly in accordance with the Software's documentation for communication with the compatible Star product you purchased (hereinafter referred to as “Star Product”); +(ii)For your own internal business operations on the Star Product on which the Software was first installed, or Star Product for which the Software was first made available by Star for use with, for production operation or, on a temporary basis, consistent with the limitations specified or referenced in this Agreement and the Software documentation; +(b) to copy the Software for installation, archival or backup purposes, and to make a sufficient number of copies for the intended use described in the Software documentation, provided that all titles and trademark, copyright and restricted rights notices are reproduced on all such copies. + +2. Restrictions on Permitted License Uses +Unless otherwise provided in this Agreement, You may not +(a)reverse engineer, disassemble, or decompile with regard to the Software or otherwise attempt to discover the trade secrets in the Software; +(b)copy, reproduce, alter, modify or create derivative works of the Software any part thereof ; +(c)sublicense, transfer, rent, lease, or redistribute the Software to a third party; +(d)use the Software for a purpose other than those specified in the preceding article. +(e)remove, delete, alter or obscure any trademarks or any copyright, trademark, patent or other intellectual property or proprietary rights notices from the Software, including any copy thereof; +(f)remove, disable, circumvent or otherwise create or implement any workaround to any copy protection, rights management or security features in or protecting the Software. + +3.Reservation of Rights. +You acknowledge and agree that the Software is provided under license, and not sold, assigned, or transferred to you. You do not acquire any ownership interest in the Software under this Agreement, or any other rights thereto other than to use the Software in accordance with the license granted, and subject to all terms, conditions and restrictions, under this Agreement. Star reserves and shall retain its entire right, title and interest in and to the Software, including all copyrights, trademarks and other intellectual property rights therein or relating thereto, except as expressly granted to you in this Agreement. + +4.Collection and Use of Your Information. +You acknowledge that when you download, install or use the Software, Star may use automatic means to collect information about your Star Product and Device and about your use of the Application for our internal business purposes and maintaining, servicing, and improving the Star Product and Applications. +Please refer to the following for more information on the collection and use of your information. +Privacy Policy for Mobile Apps: https://www.star-m.jp/prjump/000153.html + +5.Updates. +Star may from time to time in its sole discretion develop and provide Software updates, which may include upgrades, bug fixes, patches and other error corrections and/or new features (collectively, including related documentation, hereinafter referred to as "Updates"). Updates may also modify or delete in their entirety certain features and functionality. You agree that Star has no obligation to provide any Updates or to continue to provide or enable any particular features or functionality. Based on your Device settings, when your Device is connected to the internet either: +(a)the Software may automatically download and install all available Updates; or +(b)you may receive notice of or be prompted to download and install available Updates. +You shall acknowledge and agree that the Software or portions thereof may not properly operate should you fail to install the Updates. You further agree that all Updates will be deemed part of the Software and be subject to all terms and conditions of this Agreement. + +6.Term and Termination. +This Agreement is effective until terminated. Star may terminate this Agreement at any time at its sole discretion with or without notice. In addition, your rights under this Agreement will terminate automatically without notice from Star if you fail to comply with any term(s) of this Agreement. You may terminate this Agreement by deleting the Software and all copies thereof from your Device. Upon the termination of this Agreement, all rights granted to you under this Agreement will also terminate, and you shall cease all use of the Software and destroy all copies, full or partial, of the Software. Termination will not limit any of Star's rights or remedies at law or in equity. + +7. Disclaimer of Warranties +YOU EXPRESSLY ACKNOWLEDGE AND AGREE THAT USE OF THE SOFTWARE IS AT YOUR SOLE RISK AND THAT THE ENTIRE RISK AS TO SATISFACTORY QUALITY, PERFORMANCE, ACCURACY AND EFFORTS IS WITH YOU. THE SOFTWARE IS PROVIDED “AS IS”, WITH ALL FAULTS AND WITHOUT WARRANTY OF ANY KIND, AND TO THE MAXIMUM EXTENT PERMITTED BY LAW, STAR AND STAR’S LICENSORS HEREBY DISCLAIM ALL WARRANTIES AND CONDITIONS WITH RESPECT TO THE SOFTWARE, EITHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF MERCHANTABILITY, OF SATISFACTORY QUALITY, OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY, OF QUIET ENJOYMENT, AND NON-INFRINGEMENT OF THIRD PARTY RIGHTS. STAR DOES NOT WARRANT AGAINST INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE, THAT THE FUNCTIONS CONTAINED IN THE SOFTWARE WILL MEET YOUR REQUIREMENTS, THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT DEFECTS IN THE SOFTWARE WILL BE CORRECTED. NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY STAR OR STAR AUTHORIZED REPRESENTATIVE SHALL CREATE A WARRANTY. STAR IS NOT OBLIGATED TO PROVIDE ANY MAINTENANCE, TECHNICAL OR OTHER SUPPORT FOR THE SOFTWARE. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. + +8. Indemnification +You agree to indemnify, defend and hold harmless Star and its officers, directors, employees, agents, affiliates, successors and assigns from and against any and all losses, damages, liabilities, deficiencies, claims, actions, judgments, settlements, interest, awards, penalties, fines, costs, or expenses of whatever kind, including reasonable attorneys' fees, arising from or relating to your use or misuse of the Software or your breach of this Agreement. + +9. Limitation of Liability +TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL STAR BE LIABLE FOR PERSONAL INJURY, OR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES WHATSOEVER, INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, LOSS OF DATA, BUSINESS INTERRUPTION OR ANY OTHER COMMERCIAL DAMAGES OR LOSSES, ARISING OUT OF OR RELATED TO YOUR USE OR INABILITY TO USE THE SOFTWARE, HOWEVER CAUSED, REGARDLESS OF THE THEORY OF LIABILITY (CONTRACT, TORT, OR OTHERWISE) AND EVEN IF STAR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN ANY EVENT, STAR SHALL NOT BE LIABLE FOR ANY DAMAGES, IN THE AGGREGATE, REGARDLESS OF TYPE OR KIND, WHETHER IN CONTRACT OR TORT, IN EXCESS OF THE ACTUAL LICENSE FEES, IF ANY, PAID BY YOU FOR THE SOFTWARE IN THE THREE (3) MONTHS IMMEDIATELY PRECEDING THE FIRST EVENT GIVING RISE TO LIABILITY. + +10.Export Regulation. +The Software may be subject to laws and regulations including the “Foreign Exchange and Foreign Trade Act”, related regulations and the US Export Administration Act or other export control laws of other countries. You shall not, directly or indirectly, export, re-export or release the Software to, or make the Software accessible from, any jurisdiction or country to which export, re-export or release is prohibited by law, rule or regulation. You shall comply with all applicable laws, regulations and rules, and complete all required undertakings (including obtaining any necessary export license or other governmental approval), prior to exporting, re-exporting, releasing or otherwise making the Software available outside any jurisdiction or territory. + +11.Confidentiality +You shall not or divulge any of Star’s technical, business, or other operational information (hereinafter referred to as "Confidential Information") that you learn in connection with this Agreement or the use of the Software and shall use the Confidential Information only for purposes directly related to the use of the Software. However, Confidential Information does not include any information which: +(a) was in the public domain at the time of disclosure; +(b) Was already known to the recipient at the time of disclosure; +(c) was Lawfully received from a third party without any obligation of confidentially +(d) is independently developed without using the Confidential Information + +12. Third-party Software +If the whole or part of the Software includes any third-party software or intellectual property right including, but not limited to, open source software (hereinafter referred to as the "Third-party Software"), you shall comply with the terms and conditions of the license granted by the third party related to your use of the Third-party Software. In no event shall any of the provisions of this Agreement be construed as a limitation on the right of the third party to enforce each and every terms and conditions of the license. In no event shall Star be liable for any limitation on the use of the Software, which might be imposed by enforcement of the license by the third party. If the Software includes the Third-party Software, you will find the particulars thereof including the licensing conditions in the "SoftwareLicenseAgreementAppendix.pdf" or other documentation provided by Star. All Third-party Software is provided as-is, with all faults and without warranties of any kind. + +13. Governing Law and Severability +This Agreement will be governed by and construed in accordance with the laws of Japan. If for any reason a court of competent jurisdiction finds any provision, or portion thereof, to be unenforceable, the remainder of this Agreement shall continue in full force and effect. + +14.Entire Agreement. +This Agreement constitutes the entire agreement between you and Star with respect to the Software and supersede all prior or contemporaneous understandings and agreements, whether written or oral, with respect to the Software. + +15.Waiver. +No failure to exercise, and no delay in exercising, on the part of either party, any right or any power hereunder shall operate as a waiver thereof, nor shall any single or partial exercise of any right or power hereunder preclude further exercise of that or any other right hereunder. In the event of a conflict between this Agreement and any applicable purchase or other terms, the terms of this Agreement shall govern. + +16. Compensation for damages +If you fail to comply with any term of this Agreement, Star has the right to terminate this Agreement and any other agreement made with you and claim compensation for damages suffered resulting from such termination. + +17. Amendment and Alteration +You should be aware that we may change this Agreement at any time. In the event of a change, we will inform you of the change and changed version of this Agreement by displaying it on Star’s website or by other appropriate means. Unless otherwise specified, the changed version of this Agreement shall become effective when displayed on Star’s website. To read our latest Software License Agreement, please visit this page. + + + +Ⅱ.Terms and Conditions for Developers (Addendum to the General Terms and Conditions) + +If you are Star Development partner and the Software contains STAR’s software developer’s tool kit (hereinafter referred to as “SDK“) or API, your use of the SDK and API is governed by the terms of this “Terms and Conditions for Developers” in addition to the I.General Terms and Conditions. In the event of any conflict between the terms of the I.General Terms and Conditions and this Terms and Conditions for Developers, the terms of this Terms and Conditions for Developers shall govern. You should carefully read the following terms and conditions before using the SDK and API provided by STAR. +The following teams Shall have the following meanings: +The “SDK” is defined as the downloadable package of libraries, applications, and documentation that you may use solely in connection with development and testing of your software application(hereinafter referred to as “Application”) to enable it to communicate with a Star Product or device, as provided herein (hereinafter referred to as the “Permitted Use”). +The “API” is defined as the Application Programing interface information, specifications and documentation provided as a download for your Permitted Use. + +1. LICENSE +Star grants you a limited, non-exclusive, non-transferable license to use the SDK and API, including the human readable code of the SDK (hereinafter referred to as “Source Code”), subject to the terms and restrictions set forth in I.General Terms and Conditionsthis and Terms and Conditions for Developers. + +2.Use of Source Code +The SDK is licensed to be used on any personal computer or networked machines, provided that the SDK is used only in connection with the Permitted Use. You may use the Source Code internally to engage in the Permitted Use and you may use, modify or merge all or portions of the Source Code with your Application and distribute it only as part of your Application in object code form only. + + + +To read our latest Software License Agreement, please visit the following URL. +https://www.star-m.jp/wp-content/uploads/SoftwareLicenseAgreement_web.pdf + +Copyright (c) 2013-2021 Niels Lohmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE \ No newline at end of file diff --git a/README.md b/README.md index 78271bc..5a6152f 100755 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ # cloudprnt-sdk -## SDK Introduction +## Introduction -Star CloudPRNT is an openly documented JSON/REST based HTTP protocol, and therefore it is not necessary to have an SDK in order to implement a CloudPRNT compatible service. +Star CloudPRNT is a protocol that enables printing to a printer and peripheral device control from a back-end service on a remote server. CloudPRNT servers can be created using any server side technology that can be used to implement web services. Very many server side technologies are widely used such as PHP, Node.js, ASP.Net, ASP.Net Core, JSP, Python, Lua, and many more. @@ -26,13 +26,17 @@ For integration purposes, the SDK provides the following: - **.NET API**
-A .Net Standard 2.0 compatible library, which can be installed via NuGet into any .Net 4.6 or later, and .Net Core 2.0 or later project. This API provides job format conversion, status decoding, and ready made classes for serializing/de-serializing CloudPRNT JSON messages. +A .Net Standard 2.0 compatible library, which can be installed via NuGet into .NET Framework 4.6.1 or later, and .NET Core 2.0 or later project. This API provides job format conversion, status decoding, and ready made classes for serializing/de-serializing CloudPRNT JSON messages.
+For more details, please refer our [Online Manual](https://star-m.jp/products/s_print/sdk/StarCloudPRNT/manual/en/api-guide.html). - **cputil** ([CloudPRNTSDKSamples](CloudPRNTSDKSamples))
+CPUtil is a useful back-end tool to help with implementing CloudPRNT servers that are not .NET framework or .NET Core-based. +Since its source code is published, server developers can implement necessary functions by freely modifying CPUtil as necessary.
A stand-alone command line tool that can be integrated with any server-side development system that can invoke local processes. This tool can be provided as native binaries for Linux x86, Linux x64, Linux Arm, Mac OS x64, Windows x86 and Windows x64 servers (it is not necessary to install the .Net Framework or .Net Core runtime). environments in order to use it. And this tool uses the [.NET API](#.Net-API). - **Star Document Markup**
-A simple, unified printer markup language that can adapt to any Star printer regardless of emulation, print width, or print method. It is a higher level language that abstracts away the need to know printer-specific escape sequences. It does this by providing easy to use tags for various POS printer functions such as cut, alignment, image printing, and text formatting. Using the document markup system provides a balance between full bit-image based printing, and plain text output, while being easier to use than printer-specific commands. In order to take advantage of the markup language you must use it in conjunction with cputil. +A simple, unified printer markup language that can adapt to any Star printer regardless of emulation, print width, or print method. It is a higher level language that abstracts away the need to know printer-specific escape sequences. It does this by providing easy to use tags for various POS printer functions such as cut, alignment, image printing, and text formatting. Using the document markup system provides a balance between full bit-image based printing, and plain text output, while being easier to use than printer-specific commands. In order to take advantage of the markup language you must use it in conjunction with cputil.
+For more details, please refer our [Online Manual](https://star-m.jp/products/s_print/sdk/StarDocumentMarkup/manual/en/index.html). - **Sample Projects** ([ExampleServers](ExampleServers))
Examples of very simple CloudPRNT servers. The sample serves as the examples of implementing the CloudPRNT protocol and how to integrate either the cputil. diff --git a/docs/README_JP.md b/docs/README_JP.md index f89de04..65b3227 100755 --- a/docs/README_JP.md +++ b/docs/README_JP.md @@ -5,7 +5,7 @@ ## SDK概要 -Star CloudPRNTは、オープンに文書化されたJSON / RESTベースのHTTPプロトコルであるため、CloudPRNT互換サービスを実装するためにSDKを使用する必要はありません。 +Star CloudPRNTは、リモートサーバーのバックエンドサービスからプリンターへの印刷および周辺機器制御を可能とするプロトコルです。 CloudPRNTサーバーは、Webサービスの実装に使用できる任意のサーバー側テクノロジーを使用して作成できます。 PHP、Node.js、ASP.Net、ASP.Netコア、JSP、Python、Luaなど、非常に多くのサーバー側テクノロジーが広く使用されています。 @@ -28,13 +28,15 @@ PHP、Node.js、ASP.Net、ASP.Netコア、JSP、Python、Luaなど、非常に - **.NET API**
-.Net 4.6以降および.Net Core 2.0以降のプロジェクトにNuGetを介してインストールできる.Net Standard 2.0互換ライブラリです。このAPIは、印刷ジョブ形式変換、ステータスデコード、およびCloudPRNT JSONメッセージをシリアライズ/デシリアライズするための既製のクラスを提供します。 +.NET Framework 4.6.1以降および.NET Core 2.0以降のプロジェクトにNuGetを介してインストールできる.Net Standard 2.0互換ライブラリです。このAPIは、印刷ジョブ形式変換、ステータスデコード、およびCloudPRNT JSONメッセージをシリアライズ/デシリアライズするための既製のクラスを提供します。
+詳細は[オンラインマニュアル](https://star-m.jp/products/s_print/sdk/StarCloudPRNT/manual/ja/api-guide.html)をご参照ください。 - **cputil** ([CloudPRNTSDKSamples](../CloudPRNTSDKSamples))
ローカルプロセスを呼び出すことができるサーバー側の開発システムと統合できるスタンドアロンのコマンドラインツールです。 このツールは、Linux x86、Linux x64、Linux Arm、Mac OS x64、Windows x86、およびWindows x64環境のサーバーのネイティブバイナリとして提供します(.Net Frameworkまたは.Net Coreランタイムをインストールする必要はありません)。また、このツールは[.NET API](#.Net-API)を使用しています。 - **Starドキュメントマークアップ**
-エミュレーション、印刷幅、印刷方法に関係なく、任意のStarプリンターに適応できるシンプルなプリンター用マークアップ言語です。これは、プリンター固有のエスケープシーケンスを知る必要性を抽象化する言語です。 これは、カット、位置合わせ、画像印刷、テキストの書式設定など、様々なPOSプリンター機能に使いやすいタグを提供することで実現しています。ドキュメントマークアップシステムを使用すると、プリンター固有のコマンドのみで印刷ジョブの構成を作成するよりも扱いやすい一方で、フルビットイメージベースの印刷とプレーンテキスト出力のバランスが取れます。また、マークアップ言語を活用するにはcputilと組みあわせて使用​​する必要があります。 +エミュレーション、印刷幅、印刷方法に関係なく、任意のStarプリンターに適応できるシンプルなプリンター用マークアップ言語です。これは、プリンター固有のエスケープシーケンスを知る必要性を抽象化する言語です。 これは、カット、位置合わせ、画像印刷、テキストの書式設定など、様々なPOSプリンター機能に使いやすいタグを提供することで実現しています。ドキュメントマークアップシステムを使用すると、プリンター固有のコマンドのみで印刷ジョブの構成を作成するよりも扱いやすい一方で、フルビットイメージベースの印刷とプレーンテキスト出力のバランスが取れます。また、マークアップ言語を活用するにはcputilと組みあわせて使用​​する必要があります。
+詳細は[オンラインマニュアル](https://star-m.jp/products/s_print/sdk/StarDocumentMarkup/manual/ja/index.html)をご参照ください。 - **サンプルプロジェクト** ([ExampleServers](../ExampleServers))
非常に単純なCloudPRNTサーバーサンプルで、CloudPRNTプロトコルの実装例とcputilをインテグレーションする方法例として機能します。
DeviceStatusQueueClient TypeLast Connection
DeviceStatusQueuePrintingClient TypeLast Connection
" + device.mac + "" + device.status + "" + device.queueName + "" + printing + "" + device.clientType + " (" + device.clientVersion + ")" + lastConnect.toLocaleString() + ""; - table += "Show"; + table += "Show
"; + table += ' Get Status (MQTT)
'; table += ' Delete'; + table += ' Reset'; table += "