Electronic cash register and control method thereof

CN122290257BActive Publication Date: 2026-10-16GUANGZHOU ZONERICH COMP EQUIP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610602747.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-04-30
Publication Date
2026-10-16
Estimated Expiration
2046-04-30

AI Technical Summary

Technical Problem

[0004]但是,传统电子收款机在无文件系统的裸机环境下处理大量业务数据时,可能出现高频读取的商品资料与不断追加的交易日志交错存放,引发严重的跨区寻址延迟与系统卡顿;同时,新增日志需全局遍历寻找空白地址,不仅消耗大量算力且易致总线挂起;此外,结算并发执行的打印与日志落盘过程通常为单向开环机制,若遭遇外部干扰则容易发生数据漏写或脏写,导致呈现给顾客的纸质凭证与机器底层电子账目不符

Benefits of technology

本发明通过获取存储空间的分区边界参数,并在高频收银操作触发时执行地址边界的鉴权判定,拦截异构数据的越界访问,从而彻底减少传统裸机系统中因跨区寻址引发的系统拥塞与前端响应延迟发生的可能性。本发明基于已有日志条目计算并生成动态的日志写偏移指针,在执行定长交易凭证数据包的追加写入时,能够以时间复杂度为的方式得到目标物理地址,降低了常规遍历寻址带来的算力损耗。本发明构建了写入、回读比对验证、确认后物理输出的闭环落盘机制,底层数据块校验无误后驱动打印设备输出凭证,从减少了外部干扰引发的脏写与漏写。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122290257B_ABST
    Figure CN122290257B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of cash register, and relates to an electronic cash register and a control method thereof.The electronic cash register comprises a display unit, a keyboard, a printer, a storage unit, a communication unit, a cash box interface and a master control unit.The display unit comprises a main display and a customer display.The communication unit comprises a USB interface and / or an RS232 interface.The cash box interface is used for controlling the cash box to pop up.The master control unit is connected with the display unit, the keyboard, the printer, the storage unit and the cash box interface respectively.The present application protects the front-end interface response in the high-frequency cash register scene, reduces the calculation power consumption and the bus suspension problem caused by the addition of many logs, and reduces the dirty write and the missing write caused by external interference.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention generally relates to the field of cash register technology. More specifically, this invention relates to an electronic cash register and its control method. Background Technology

[0002] Electronic Cash Registers (ECRs) are indispensable core business terminals in the modern retail and catering industries, undertaking multiple key tasks such as front-end product entry, complex amount calculation, invoice printing, and persistent storage of underlying financial data. With the increasing complexity of commercial retail scenarios, merchants are placing extremely high demands on the product inventory capacity (PLU data) and retention period of historical transaction records (electronic logs) of ECRs.

[0003] Traditional electronic POS machines typically use low-cost microcontrollers as the main control unit. However, due to the extremely small capacity of the microcontroller's internal static random access memory (SRAM), massive amounts of business data must rely on external serial non-volatile memory for long-term storage.

[0004] However, when traditional electronic POS machines process large amounts of business data in a bare-metal environment without a file system, the frequent reading of product information and the continuous addition of transaction logs may be interspersed, causing serious cross-regional addressing delays and system lag. At the same time, adding new logs requires a global traversal to find blank addresses, which not only consumes a lot of computing power but also easily causes the bus to hang. In addition, the printing and log writing process executed concurrently by the settlement is usually a one-way open-loop mechanism. If it encounters external interference, data omissions or dirty writes are likely to occur, resulting in discrepancies between the paper vouchers presented to customers and the underlying electronic accounts of the machine. Summary of the Invention

[0005] To address the technical problems of system lag and discrepancies between accounts and actual transactions caused by inefficient addressing when processing business data in existing electronic cash registers, this invention provides solutions in the following aspects.

[0006] In a first aspect, an electronic cash register includes: an input / output unit; a display unit including a main display and a customer display; a communication unit including a USB interface and / or an RS232 interface; and a main control unit connected to the display unit, the storage unit, and the input / output unit respectively. The main control unit is configured to: obtain a system parameter set and execute self-test programs for each peripheral unit; extract partition boundary parameters of the storage unit; determine the tail blank address through the log quantity; generate a log write offset pointer; obtain a keyboard trigger signal through a combination of hardware interrupt and periodic polling; calculate the target read result based on the keyboard trigger signal; after executing address boundary range judgment to intercept out-of-bounds access, retrieve the basic unit price in the product data area of ​​the storage unit and calculate the total amount to be paid based on the sales quantity and adjustment coefficient; receive a payment confirmation signal and calculate the change difference value; aggregate transaction details to generate a transaction voucher data packet and attach a data verification code; store the transaction voucher data packet into the electronic log area of ​​the storage unit according to the write offset pointer; and perform a memory readback comparison operation.

[0007] Preferably, the main control unit is a microcontroller based on the ARM Cortex-M3 core, and the microcontroller includes at least an SPI interface, a USART interface, a USB interface, and multiple GPIO pins.

[0008] Preferably, the input / output unit includes a printer, a cash drawer interface, and a keyboard. The cash drawer interface is used to control the cash drawer to open. The printer is a thermal printer, which includes an SPI interface and a motor driver chip. The printer is connected to the main control unit through the SPI interface and controls the paper feeding action through the motor driver chip.

[0009] Preferably, the storage unit is a serial Flash memory with an SPI interface.

[0010] Preferably, the serial Flash memory is model GD25Q32CSIG, and its physical storage area is divided into system parameter area, PLU product data area and electronic log area.

[0011] Preferably, the main control unit is configured with a layered modular software system, which includes: a driver layer for encapsulating peripheral drivers and providing a hardware abstraction interface; a middleware layer for data management, event scheduling, and protocol parsing, supporting partitioned storage management of PLUs, categories, and electronic logs; and an application layer including a system settings module, a data management module, a product sales module, a report statistics module, and a backend online module. The product sales module handles category sales, PLU sales, open-price sales, repeat sales, multi-quantity sales, discounts / surcharges, cancellation, refunds, multiple payment methods, and foreign currency settlement. The report statistics module generates X / Z daily reports, monthly reports, category reports, PLU reports, cashier reports, and electronic log reports. The backend online module supports product data synchronization, transaction data upload, and firmware upgrades with PC software via USB or serial port.

[0012] Preferably, the power supply unit converts the external input voltage into a first operating voltage to power the printing unit; and further steps down the first operating voltage to convert it into a second operating voltage to power the main control unit and the display unit.

[0013] In a second aspect, a control method for an electronic cash register as described in any of the above inventions includes: obtaining a system parameter set and executing self-test programs for each peripheral unit; extracting partition boundary parameters of the storage unit; determining the tail blank address through the number of logs; generating a dynamic log write offset pointer in the cache; obtaining a keyboard trigger signal through a combination of hardware interrupt and periodic polling; calculating the target read result based on the keyboard trigger signal; performing address boundary range judgment to intercept out-of-bounds access; retrieving the basic unit price in the commodity data area of ​​the storage unit and calculating the total amount to be paid based on the sales quantity and adjustment coefficient; receiving a payment confirmation signal and calculating the change difference value; aggregating transaction details to generate a transaction voucher data packet and attaching a data verification code; storing the transaction voucher data packet in the electronic log area of ​​the storage unit according to the write offset pointer; performing a memory readback comparison operation, wherein in response to the readback data and the verification code matching, driving the printer to output the transaction voucher data packet as a transaction receipt and synchronously accumulating and updating the write offset pointer.

[0014] Preferably, the memory readback comparison operation includes: when the transaction certificate data packet is stored as a log entry in the electronic log area of ​​the storage unit, performing integrity verification on the data written to the storage unit using a cyclic redundancy check algorithm.

[0015] Preferably, it further includes: receiving a firmware upgrade data packet sent by an external computer through the communication unit, and performing a firmware overwrite update after verifying the version information.

[0016] The beneficial effects of this invention are as follows: This invention obtains the partition boundary parameters of the storage space and performs address boundary authentication when triggered by high-frequency checkout operations, intercepting out-of-bounds access to heterogeneous data, thereby completely reducing the possibility of system congestion and front-end response delays caused by cross-partition addressing in traditional bare-metal systems. Based on existing log entries, this invention calculates and generates a dynamic log write offset pointer. When appending fixed-length transaction voucher data packets, it can obtain the target physical address in a time complexity of O(log n), reducing the computational cost of conventional traversal addressing. This invention constructs a closed-loop disk-based mechanism for writing, reading back for comparison and verification, and physical output after confirmation. After the underlying data blocks are verified to be correct, the printing device is driven to output the voucher, reducing dirty writes and missed writes caused by external interference. Attached Figure Description

[0017] The above and other objects, features, and advantages of exemplary embodiments of the present invention will become readily apparent upon reading the following detailed description with reference to the accompanying drawings. In the drawings, several embodiments of the invention are illustrated by way of example and not limitation, and like or corresponding reference numerals denote like or corresponding parts, wherein: Figure 1 This is a schematic block diagram illustrating the structure of an electronic cash register according to an embodiment of the present invention; Figure 2 This is a schematic flowchart illustrating the steps of a control method for an electronic cash register according to an embodiment of the present invention. Detailed Implementation

[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0019] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0020] Figure 1 This is a schematic block diagram illustrating the structure of an electronic cash register according to an embodiment of the present invention.

[0021] like Figure 1As shown, an electronic cash register includes: an input / output unit; a display unit, including a main display and a customer display; a communication unit, including a USB interface and / or an RS232 interface; and a main control unit, which is connected to the display unit, the storage unit, and the input / output unit respectively. The main control unit is configured to: obtain a system parameter set and execute self-test programs for each peripheral unit; extract partition boundary parameters of the storage unit; determine the tail blank address through the number of logs; generate a log write offset pointer; obtain a keyboard trigger signal through a combination of hardware interrupt and periodic polling; calculate the target read result based on the keyboard trigger signal; after executing address boundary range judgment to intercept out-of-bounds access, retrieve the basic unit price in the product data area of ​​the storage unit and calculate the total amount to be paid based on the sales quantity and adjustment coefficient; receive a payment confirmation signal and calculate the change difference value; aggregate transaction details to generate a transaction voucher data packet and attach a data verification code; store the transaction voucher data packet into the electronic log area of ​​the storage unit according to the write offset pointer; and perform a memory readback comparison operation.

[0022] The keyboard is a matrix programmable keyboard.

[0023] In one embodiment, the input / output unit includes a printer, a cash drawer interface, and a keyboard. The cash drawer interface is used to control the cash drawer to open. The printer is a thermal printer, which includes an SPI interface and a motor driver chip. The printer is connected to the main control unit through the SPI interface and controls the paper feeding action through the motor driver chip.

[0024] In one embodiment, the main control unit is a microcontroller based on the ARM Cortex-M3 core, and the microcontroller includes at least an SPI interface, a USART interface, a USB interface, and multiple GPIO pins.

[0025] The main control unit uses a microcontroller based on the ARM Cortex-M3 core. As the data processing and control hub of the entire electronic cash register, it realizes high-speed data interaction and command issuance with various peripheral hardware devices through the internally integrated serial peripheral interface, universal synchronous and asynchronous transceiver, universal serial bus and universal input and output pins.

[0026] In one embodiment, the storage unit is a serial Flash memory with an SPI interface.

[0027] In one embodiment, the serial Flash memory is model GD25Q32CSIG with a capacity of 32Mbit, and its physical storage area is divided into a system parameter area, a PLU product data area, and an electronic log area.

[0028] The storage unit employs a serial Flash memory with a serial peripheral interface, and its physical storage area is divided into a system parameter area, a PLU product data area, and an electronic log area. The system parameter area stores the device's basic configuration; the PLU product data area stores downloaded product information; and the electronic log area supports writing and reading electronic logs to securely store settled transaction records.

[0029] In one embodiment, the printer is a thermal printer, which includes an SPI interface and a motor drive chip. The printer is connected to the main control unit through the SPI interface and controls the paper feeding action through the motor drive chip.

[0030] Specifically, the printer is a thermal printer that receives control commands from the main control unit to print transaction receipts. The printer connects to the main control unit via a serial peripheral interface to receive print data streams and controls the paper feed via a configured motor drive chip, thereby converting transaction details into physical paper vouchers for output.

[0031] In one embodiment, the main control unit is configured with a layered modular software system, wherein the layered modular software system includes: a driver layer, which is used to encapsulate peripheral drivers and provide hardware abstraction interfaces; a middleware layer, which is used for data management, event scheduling and protocol parsing, and the middleware layer supports partitioned storage management of PLU, categories and electronic logs; and an application layer, which includes a system settings module, a data management module, a product sales module, a report statistics module and a background online module.

[0032] The product sales module is used for category sales, PLU sales, open price sales, repeat sales, multi-quantity sales, discounts / surcharges, cancellation, refunds, multiple payment methods, and foreign currency settlement functions; the report statistics module is used for X / Z daily reports, monthly reports, category reports, PLU reports, cashier reports, and electronic log reports; the backend online module supports synchronization of product information, uploading of transaction data, and firmware upgrades with PC software via USB or serial port.

[0033] Within the application layer, various modules collaborate to achieve a complete closed-loop logic for commercial point-of-sale (POS) transactions. Specifically, the merchandise sales module encompasses everything from routine category and PLU sales, multiple quantity and repetitive data entry, to complex discount and surcharge calculations, cancellation and refund of abnormal documents, and even support for multiple payment methods and foreign currency settlements—a full-chain transaction POS function. The report statistics module is responsible for multi-dimensional data extraction and aggregation from persistent transaction logs to generate various daily, monthly, and detailed business reports for account reconciliation. The backend online module acts as a communication proxy between the terminal and remote computers, asynchronously performing batch synchronization of the merchandise database, uploading of historical transaction data, and overwriting and updating of the underlying system firmware. Through a layered and decoupled software architecture, the complex POS business logic at the upper layer is no longer deeply bound to the specific hardware electrical characteristics at the lower level, improving operational throughput and code portability across hardware platforms.

[0034] In one embodiment, an electronic cash register further includes a power supply unit that converts an external input voltage into a first operating voltage to power the printing unit; and further steps down the first operating voltage to convert it into a second operating voltage to power the main control unit and the display unit.

[0035] The first operating voltage is typically the high-current output required for the thermal printer's drive motor to feed paper and for the heating head to generate transient heat. The second operating voltage is precisely clamped to the low-voltage operating range required by the microcontroller and logic chips. This tiered power management strategy, which involves first stepping down the high-voltage, high-current primary voltage and then stepping down the low-voltage, precise secondary voltage, not only filters out the ripple from the external input power supply but also reduces reverse surge interference generated by high-power electromechanical peripherals during frequent start-ups and shutdowns at the underlying physical circuit level. This ensures the electrical stability of the main control unit during high-frequency data processing and memory read / write operations.

[0036] The present invention implements a control method for the electronic cash register through the main control unit. Figure 2 This is a flowchart illustrating the steps of a control method for an electronic cash register according to an embodiment of the present invention.

[0037] like Figure 2 As shown, a control method for an electronic cash register applied to any one of the first aspects includes steps S1 to S5.

[0038] Step S1: Obtain the system parameter set and execute the self-test program of each peripheral unit, extract the partition boundary parameters of the storage unit, determine the tail blank address by the number of logs, and generate the log write offset pointer.

[0039] The system parameter set refers to the configuration data necessary for the electronic cash register to maintain basic operation, such as communication baud rate, device terminal number, printer density level, and system time; the peripheral units refer to the various physical functional modules that establish electrical and communication connections with the main control unit, such as matrix keyboard, display, printer, memory, and cash drawer; the self-test program is the low-level initialization code that the main control unit sends detection signals to each peripheral unit after power-on reset to confirm its physical connection status and logical ready status.

[0040] Further, step S1 includes steps S101 to S104.

[0041] Step S101: Send a data frame read instruction to the first address sector of the external non-volatile memory via the SPI interface to load the pre-frozen memory partition mapping table into the internal static random access memory.

[0042] Step S102: Obtain the memory partition mapping table, extract and cache the starting base address and capacity boundary upper limit of the system parameter area, product data area, and electronic log area; construct a legal physical address range for any storage area. ,in A i Let i be the starting base address of the i-th memory region. S max,i The maximum number of bytes pre-allocated for the i-th storage area.

[0043] Step S103: For the electronic log area, perform an empty / full status scan by reading the log record header identifier to determine the total number N of valid transaction records that have been successfully persisted to disk; call the offset address calculation formula to calculate the next blank writable address, where the calculation formula is: .

[0044] in, A next The latest tail blank address is calculated. A log The base address of the extracted electronic log area, L Fixed byte length for a single transaction certificate data packet Step S104: After calculating the next blank writable address, extract the predecessor address. The last historical transaction log block stored is retrieved, and a cyclic redundancy check is performed. If the checksum matches, confirming that the log list is not corrupted, the transaction is then stored in the internal cache. A next The formal assignment and activation are performed as a dynamic log append address pointer.

[0045] It should be noted that this invention constructs secure data write boundaries and generates error-proof pointers through a low-level addressing algorithm. Specifically, firstly, a pre-fixed memory partition mapping table is loaded into the internal static random access memory via a serial peripheral interface, thereby establishing a legal physical address range for each storage area, including the starting base address and the upper limit of the capacity boundary. Subsequently, the next blank writable address is calculated by combining the extracted electronic log area base address, the fixed byte length of a single transaction voucher data packet, and the total number of currently valid transaction records. To prevent log chain breaks, the system does not write blindly, but instead extracts the last historical transaction log block at the predecessor address and performs cyclic redundancy check back calculation. Only when the verification signature matches will the calculated latest tail blank address be activated as a dynamic log append addressing pointer. Based on this, the security of addressing a large number of logs is improved.

[0046] Step S2: Obtain the keyboard trigger signal by combining hardware interrupts with periodic polling.

[0047] The combination of hardware interrupt and periodic polling means that when the microcontroller captures the input signal at the bottom layer, it first uses the edge-triggered interrupt feature of the pin to capture the level transition action at the very short moment when the button is pressed to ensure the real-time response; then the interrupt is immediately disabled and a timer with a fixed period is started to poll, and the input is confirmed only after the button level state is stable, thereby filtering out stray high-frequency glitches generated at the moment of contact of the mechanical button spring.

[0048] Further, step S2 includes steps S201 to S203.

[0049] Step S201: When a transient level change caused by a physical press of the matrix keyboard is detected, a hardware interrupt is triggered and the current interrupt trigger timestamp is recorded. Step S202: Disable the interrupt of the current pin and start a preset delay polling timer; after the timer overflows, actively read the pin level status. If the level remains stable at a low level, it is confirmed as a valid physical press, and mechanical bounce glitches are filtered out.

[0050] Step S203: Combine the row and column scan codes of the matrix keyboard to query the internal key value mapping table and convert it into a standard operation instruction set containing specific product identification codes or control instructions.

[0051] It should be noted that this invention constitutes a fault-prevention conversion process from analog physical actions to digital logic instructions. Specifically, when a transient level change caused by a physical key press on the matrix keyboard is detected, a hardware interrupt is triggered and a timestamp is recorded. Subsequently, debouncing is performed by actively reading the pin level status to ensure that the recorded physical key press is valid. By using row and column scanning encoding to query the internal key value mapping table, the physical coordinates are accurately converted into a standard operation instruction set containing specific product identification codes or control instructions, thereby reducing misreading of consecutive keys or missed readings in blind spots.

[0052] Step S3: Calculate the target read based on the keyboard trigger signal, execute address boundary range judgment to intercept out-of-bounds access, retrieve the basic unit price in the product data area of ​​the storage unit, and calculate the total amount to be paid based on the sales quantity and adjustment coefficient.

[0053] The process of calculating the total amount to be paid is as follows: The main control unit retrieves the corresponding basic unit price from the storage unit based on the product identification codes extracted from the product operation instruction set. The basic unit price is then multiplied by the corresponding sales quantity entered by the cashier via keyboard and the promotion adjustment coefficient set in the current system for the product to obtain the actual amount payable for the single product. Subsequently, the actual amounts payable for all types of products in the current transaction batch are added together to finally obtain the total amount to be paid.

[0054] Further, step S3 includes steps S301 to S303.

[0055] Step S301: Obtain the parsed product identification code ID Combined with the base address of the cached product data area A d and the length of a single product record L d Calculate the absolute physical address of the target product. A r The calculation formula is as follows: .

[0056] Step S302: If the formula If the address is valid, the addressing is considered valid; otherwise, the read is rejected.

[0057] Step S303: After the addressing is valid, send the starting address to the non-volatile memory via the SPI interface. A r The continuous read instructions load the corresponding product's basic unit price and attribute parameters into the internal memory.

[0058] It should be noted that this invention provides a high-frequency data retrieval mechanism strictly constrained by physical boundaries. Specifically, the absolute physical read address of the target product is calculated using the base address of the product data area, the length of a single product record, and the product identification code. Before initiating a read operation via the serial peripheral interface bus, it is forcibly determined whether the read address is within a valid range. If it exceeds this valid range, an abnormal interrupt is triggered to refuse reading. This pre-determination mechanism effectively prevents the product data read pointer from erroneously reading data from the system parameter area or electronic log area due to abnormal out-of-bounds errors, ensuring memory safety during the high-frequency retrieval process.

[0059] Step S4: Receive payment confirmation signal and calculate change difference, aggregate transaction details to generate transaction voucher data packet and attach data verification code.

[0060] The transaction details include specific information about each product entered during a single checkout process, such as product identification code, basic unit price, sales quantity, and promotional adjustment coefficient. The transaction voucher data package is the final structured data carrier used by the system for persistent storage and printing. The specific process of aggregating transaction details to obtain the transaction voucher data package is as follows: After receiving the settlement control instruction, the main control unit, according to a preset byte alignment format, concatenates the currently generated unique transaction serial number, the calculated total amount, the aforementioned product detail data blocks, and the current system timestamp in a fixed order, and packages them into a data package of a preset fixed byte length in the internal memory.

[0061] Further, step S4 includes steps S401 to S402.

[0062] Step S401: Calculate the total amount to be paid in real time based on the retrieved basic unit price of the goods, the input sales quantity, and the promotion adjustment coefficient. The calculation formula is as follows: .

[0063] in, n For all kinds of goods, for the first j This type of commodity Price j Based on the unit price, D j This is a promotion adjustment coefficient. Qty j This refers to the sales volume.

[0064] Step S402: Upon receiving the settlement control instruction, the discrete data such as transaction serial number, total amount, details of each commodity, and timestamp are internally concatenated and aggregated into a fixed-length array according to a preset byte alignment format. L r The data packet containing the transaction credentials to be written.

[0065] It should be noted that steps S401 to S402 complete the mathematical operations and physical encapsulation of the transaction data. The system calculates the total amount to be paid in real time by multiplying and summing the base unit price, promotion adjustment coefficient, and sales quantity of each product. Subsequently, upon receiving the settlement control instruction, the system internally concatenates and aggregates the calculated total amount with discrete data such as transaction serial number and timestamp, according to a preset byte alignment format, into a fixed-length transaction voucher data packet to be written. This fixed-length conversion of discrete business data is a prerequisite for subsequent fixed-step append writing of storage units and precise pointer calculation.

[0066] Step S5: Store the transaction certificate data packet into the electronic log area of ​​the storage unit according to the write offset pointer.

[0067] The electronic log area of ​​the storage unit is a set of physical sectors specifically used for linearly appending and storing completed transaction voucher data packets in a time-series manner. The storage unit employs a partitioned architecture because the heterogeneous data encountered by the POS terminal during operation has completely different read / write lifecycles: the system parameter area requires high-frequency reading but very little modification; the product data area requires random high-frequency retrieval; and the electronic log area requires high-frequency linear appending and writing. Physical partitioning avoids cross-page erasure interference to static basic parameters caused by frequent log appending, thereby improving data retrieval efficiency and extending the lifespan of the non-volatile memory.

[0068] In one embodiment, when the transaction certificate data packet is stored as a log entry in the electronic log area of ​​the storage unit, the integrity of the data written to the storage unit is verified by a cyclic redundancy check algorithm.

[0069] Further, step S5 includes steps S501 to S504.

[0070] S501: For the encapsulated transaction certificate data packet, execute the cyclic redundancy check algorithm to generate a fixed-length integrity check signature, and append it to the end of the data packet to form a complete write data block.

[0071] S502: Retrieve the dynamic log append address pointer residing in the cache A next As the target address for writing, a data block with a signature is written to the non-volatile memory via the SPI interface.

[0072] S503: After the write instruction is completed, immediately send a readback instruction to the non-volatile memory from address [address]. A next The data block is read out again and the verification algorithm is executed again. The verification result is then compared with the generated feature code.

[0073] S504: If the comparison results are consistent, confirming that the data has been completely written to disk, output a level signal to drive the printer to execute the voucher printing; at the same time, update the log append address pointer in the internal cache, release bus resources, and prepare for the next transaction processing.

[0074] The process of updating the logs in the internal cache includes: adding a fixed byte length of the single transaction certificate data packet to the current value of the log append address pointer in the internal cache, so as to update the value of the log append address pointer and point it to the next blank physical address to be written.

[0075] Step S6: Perform a memory readback and comparison operation, wherein in response to the readback data matching the check code, drive the printer to output the transaction voucher data packet as a transaction slip, and synchronously accumulate and update the write offset pointer.

[0076] It should be noted that this invention constructs a write-to-read and comparison mechanism for data storage. Specifically, a cyclic redundancy check (CRC) algorithm is executed on the packaged transaction voucher data packet to generate a signature code, which is appended to the end. Then, an addressing pointer is added using a dynamic log residing in the cache to write it to non-volatile memory. To prevent dirty writes due to bus interference, the data block is reread from the address pointed to by this addressing pointer and a verification algorithm is executed for comparison. Only after the comparison confirms that the data has been completely stored on disk will a print signal be output, and a fixed number of bytes will be added to the current pointer value to update the log appending addressing pointer. This fundamentally eliminates the fatal flaw of inconsistency between the underlying printing peripheral status and the actual financial data storage status.

[0077] In one embodiment, the communication unit receives a firmware upgrade data packet from an external computer and performs a firmware overwrite update after verifying the version information.

[0078] It should be noted that the process of receiving firmware upgrade data packets from an external computer via the communication unit and performing firmware overwrite updates after verifying the version information provides the electronic POS terminal with hot-fix and iterative capabilities for its underlying logic. Upon receiving the upgrade data packet, the main control unit first extracts the version information and integrity checksum from its header for verification to prevent downgrading or flashing of corrupted firmware. After successful verification, the system writes the data packet to a specific backup sector or directly overwrites the original program storage area, thereby enabling remote upgrades and functional expansion of the business logic algorithms without disassembling the hardware.

[0079] In the description of this specification, "multiple" or "several" means at least two, such as two, three or more, unless otherwise explicitly specified.

[0080] While this specification has shown and described numerous embodiments of the invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will occur to those skilled in the art without departing from the spirit and essence of the invention. It should be understood that various alternatives to the embodiments of the invention described herein may be employed in the practice of this invention.

Claims

1. An electronic cash register, characterized in that, include: Input / output unit; The display unit includes a main display and a guest display; A communication unit, which includes a USB interface and / or an RS232 interface; The main control unit is connected to the display unit, the storage unit, and the input / output unit respectively; The main control unit is configured as follows: The system obtains the system parameter set and executes the self-test program of each peripheral unit. It extracts the partition boundary parameters of the storage unit, determines the tail blank address by the number of logs, and generates a log write offset pointer. It obtains the keyboard trigger signal by combining hardware interrupts and periodic polling. It calculates the target read address based on the keyboard trigger signal, performs address boundary range judgment to intercept out-of-bounds access, retrieves the basic unit price in the commodity data area of ​​the storage unit, and calculates the total amount to be paid based on the sales quantity and adjustment coefficient. The system receives a payment confirmation signal and calculates the change difference. It aggregates transaction details to generate a transaction voucher data packet and attaches a data verification code. Based on the log write offset pointer, it stores the transaction voucher data packet into the electronic log area of ​​the storage unit. It performs a memory readback comparison operation. In response to the readback data matching the verification code, it drives the printer to output the transaction voucher data packet as a transaction receipt and synchronously updates the log write offset pointer.

2. The electronic cash register according to claim 1, characterized in that, The main control unit is a microcontroller based on the ARM Cortex-M3 core, and the microcontroller includes at least an SPI interface, a USART interface, a USB interface, and multiple GPIO pins.

3. An electronic cash register according to claim 2, characterized in that, The input / output unit includes a printer, a cash drawer interface, and a keyboard. The cash drawer interface is used to control the cash drawer to open. The printer is a thermal printer and includes an SPI interface and a motor driver chip. The printer is connected to the main control unit through the SPI interface and controls the paper feeding action through the motor driver chip.

4. An electronic cash register according to claim 1, characterized in that, The storage unit is a serial Flash memory with an SPI interface.

5. An electronic cash register according to claim 4, characterized in that, The serial Flash memory is model GD25Q32CSIG, and its physical storage area is divided into system parameter area, PLU product data area and electronic log area.

6. An electronic cash register according to claim 1, characterized in that, The main control unit is configured with a hierarchical modular software system, wherein the hierarchical modular software system includes: The driver layer encapsulates peripheral drivers and provides a hardware abstraction interface. The middle layer is used for data management, event scheduling and protocol parsing. The middle layer supports partitioned storage management of PLU, department and electronic log. The application layer includes a system settings module, a data management module, a product sales module, a report statistics module, and a backend online module; The product sales module is used for category sales, PLU sales, open price sales, repeat sales, multi-quantity sales, discounts / surcharges, cancellation, refunds, multiple payment methods, and foreign currency settlement functions; the report statistics module is used for X / Z daily reports, monthly reports, category reports, PLU reports, cashier reports, and electronic log reports; the backend online module supports synchronization of product information, uploading of transaction data, and firmware upgrades with PC software via USB or serial port.

7. An electronic cash register according to claim 1, characterized in that, It also includes a power supply unit, which converts the external input voltage into a first operating voltage to power the printing unit; and further steps down the first operating voltage to convert it into a second operating voltage to power the main control unit and the display unit.

8. A control method for an electronic cash register as described in any one of claims 1 to 7, characterized in that, include: Obtain the system parameter set and execute the self-test program of each peripheral unit, extract the partition boundary parameters of the storage unit, determine the tail blank address by the number of logs, and generate a dynamic log write offset pointer in the cache. Keyboard trigger signals are obtained by combining hardware interrupts with periodic polling; The target read address is calculated based on the keyboard trigger signal. After the address boundary range is determined and outbound access is blocked, the basic unit price is retrieved from the product data area of ​​the storage unit and the total amount to be paid is calculated based on the sales quantity and adjustment coefficient. Receive payment confirmation signal and calculate the change difference, aggregate transaction details to generate transaction voucher data package and attach data verification code; The transaction voucher data packet is stored in the electronic log area of ​​the storage unit according to the write offset pointer; a memory readback comparison operation is performed, wherein in response to the readback data matching the check code, the printer is driven to output the transaction voucher data packet as a transaction slip, and the log write offset pointer is updated synchronously.

9. The control method for an electronic cash register according to claim 8, characterized in that, The memory readback comparison operation includes: when storing the transaction certificate data packet as a log entry into the electronic log area of ​​the storage unit, performing integrity verification on the data written to the storage unit using a cyclic redundancy check algorithm.

10. The control method for an electronic cash register according to claim 8, characterized in that, Also includes: The communication unit receives firmware upgrade data packets from an external computer and performs a firmware overwrite update after verifying the version information.

Citation Information

Patent Citations

  • Method for ensuring reliable data for tax-controlling device

    CN101025844A

  • Method and device applied to printer system data verification and storage medium

    CN119473187A