madan
madan

Reputation: 783

send hexstring to a serialport

i am able to send data in terms of string to a serial port by using

fwrite($this->_dHandle, $this->_buffer,1024);

it print string on the paper but my requirement is to print image in thermal printer i have the proper hex string to print image
in c# there is a option like

comport.Write(data, 0, data.Length);

data is in the form of byte array when i convert the hex string to byte array and send it to the serial port it just print Array.Is there any overload function to send byte array to serial port in PHP5.3
Thnx in advance

Upvotes: 0

Views: 738

Answers (1)

fvu
fvu

Reputation: 32953

No, php's fwrite doesn't have such a mechanism. However, the function itself can be used with binary strings, so you just have to create a binary string, and probably the easiest way to do that is using the function pack.

Note: if your OS distinguishes between text and binary files (Windows does) the file should be opened as such (modeflag b, see the docs).

Upvotes: 0

Related Questions