Motorola mobility & Google.

 General  Comments Off on Motorola mobility & Google.
Aug 162011
 
Motorola

Motorola

Looks like, there are talks in Google Inc. for acquiring Motorola mobility for $12.5 billions.

With Motorola, Google will get the needed licenses and Patent rights to stand and fight against the competition’s lawsuits. Looks like again Microsoft, Nokia and the others want piece of the big cake.

source: boston.com

I can’t say I am not happy. I am dedicated Motorola mobile fan since Y2k. I had Talkabout, Timeport, C350, SLVR, ROKR, ROKR2 and DROID/Milestone. All my phones never broke a single part, only the first ROKR had some issues with the power socket.

I am confident that if that merge to Google actually happens, there will be benefits for all Motorola fans. Not just me. And I hope, while there are talks about/against iPhone and building a strong competitive product does not mean that my next set will be an expensive High end MotoRoid/MotoROKR as much as one iPhone costs. GoogleMoto should stick with the present company principles.

  • Accessibility.
  • Acceptable price.
  • Open source when/where possible.
  • Modding of almost everything.
  • Intuitive and Easy to use.
  • Motorola specific design tweaks.
  • Music!

Taking in consideration that Motorola already has experience with Linux based smartphones I can’t resist but speculate “Guys! Why don’t you build one mixed Droid/Linux set with dual boot?” I really want to have a real Linux sidekick in my pocket for important quick fixes in the lab. The [microUSB/bluetooth]-to-serial cable is not expensive, but I still need native terminal, not Java based one. It sucks to launch 60mb JRRE for one simple xTerm.

Add good native support for scripting languages such as Python, TCL, Perl, Ruby and others. A whole lot of useful  light programs for Android can be run this way. Even if it is not native, It can be modular. But never the less – the support is needed.

Expand the docking stations to media centers that connect to the TV set, the network and the audio receiver. One phone to communicate with everything (one phone to rule them all 😉 ). You are really one step short of doing it. It is a matter of time. (and some money)

Do not just make two-in-one company. Make a difference!

And one last sentence: Motorola. THANK YOU GUYS! Thank you for making good decision again.

 Posted by at 10:02 am
Aug 152011
 

Datecs Fiscal printers FP 3530/3550 are also known as Citizen IDP 3530/3550, so if you have that printer instead of Datecs version – this little neat program will also work for you.

I wrote this code for a Cable TV operator in the city of Sofia (Bulgaria) long ago. It is closed now, but this code was running on 50 of their cash desks (all running Slackware Linux). I did some modifications but they are lost and not retrievable anymore. Most of this is tested on 3530. 3550 is also having paper feed cutter, this code cannot cut the paper, but It can be added quick if anyone can provide a FP3550 unit for testing.

The code is a bit old and is my first Perl script, a bit chunky and raw and also I wrote Perl at this days inspired by Pascal, so if you think you can better the code – feel free to post suggestions and links. I will appreciate them.

Basically, you need to set a symlink to your printer in /dev/ or change the line pointing to the device to /dev/ttyS0 or wherever your Fiscal printer resides on the machine.

#!/usr/bin/perl -w
#
use strict;
use warnings;
use Device::SerialPort ;

# Globals

my $last_command = 0;
my $last_index = 0;
my $verbose = 0;
my $port = "/dev/FP3530"; 	# You need to set this manually with symlink to the serial port where, 
				# the fp3530 is set if you are not executinh thse script as root.
				# if you are root, you can change this line to your actual serial port.

sub encode {
# Function encode (sequence, command, data)
# sequence is between 0x20 and 0x7f
# command is described in the printer's manual
# data depends on command and can be OMITED
# encoded message must be <01><"DATA"><05><03>
	my $seq = shift;
	my $cmd = shift;
	my $data = shift;
# Cyrilize old style if needed :( the printer has Cyrilic starting from 0x80 ... must be 0xc0 to show properly
	for (my $i = 0; $i < length($data); $i++ ) {
		if (ord(substr($data,$i,1)) > 0xbf) { substr($data,$i,1) = chr(ord(substr($data,$i,1))-0x40);}
	}
	my $bcc = 0;						#bcc is the sum of all bytes after #01 including 0x05
	$bcc += ord($seq);
	$bcc += ord($cmd);
	for (my $i = 0; $i < length($data) ; $i++) {
		$bcc += ord(substr($data, $i, 1));
	}
	$bcc += 0x05;						# 0x05 is data terminator
	my $lng = 32 + 4 + length($data);			# second byte from the message is the length of 
	$bcc += $lng;						# bytes between 0x01(excl) and 0x05(incl) plus 0x20
	my $b1 = chr(0x30 + ($bcc - ($bcc % 4096)) / 4096);	# after calculating BCC must be *encoded*
	my $hlp = $bcc % 4096;					# if Checksum is 0x1234 then BCC must be 0x31 0x32 0x33 0x34
	my $b2 = chr(0x30 + ($hlp - ($hlp % 256)) / 256);
	$hlp = $bcc % 256;
	my $b3 = chr(0x30 + ($hlp - ($hlp % 16)) / 16);
	$hlp = $bcc % 16;
	my $b4 = chr(0x30 + $hlp);
	my $len = chr($lng);
	my $encoded = chr(0x01) . $len . $seq . $cmd . $data . chr(0x05) . $b1 . $b2 . $b3 . $b4 . chr(0x03) ; # <-- completed message
# Debuging
	if ($verbose) {
		my $encoded_textual = "";
		for (my $i = 0; $i < length($encoded); $i++) {
			$encoded_textual = $encoded_textual . sprintf("%02x", ord(substr($encoded,$i,1))) . "";
		}
		printf ("Encoded message : $encoded_textual\n");
	}
# end of Debuging 
	return ($encoded);
}

sub prn_reply {
	my $msg = shift;
	$last_command = ord(substr($msg,3,1));
	$last_index = ord(substr($msg,2,1));
	if ($verbose) {
		if ($msg ne "") {
			print ("Prn replied with: ");
			for (my $i = 0; $i < length($msg); $i++) {
				my $tmp = sprintf("%02x", ord(substr($msg, $i, 1)));
				if ($tmp ne "16") {
					print ($tmp . "");
				}
			}
		}
		print ("($msg)\n");

		print ("Command was : $last_command\n Index was: $last_index\n");
	}
# strip the 6 status bytes from reply message
	my $flag = "";
	my @sb;
	my $j = 0;
	for (my $i = 0; $i < length($msg); $i++) {
		my $tmp = ord(substr($msg, $i, 1));
		if ($tmp == 0x05) { $flag = "0"}
		if ($flag) {
			$sb[$j] = sprintf("%08b", $tmp);
			if ($verbose) {print("Status bits $j are ".$sb[$j],"\n");}
			$j++;
		}
		if ($tmp == 0x04) { $flag = "1"}
	}
# FATAL ERRORS
	if (substr($sb[0],2,1) eq "1") { print("Fatal Error :\n"); }
	if (substr($sb[0],3,1) eq "1") { print(" Mechanics Error !\n"); }
	if (substr($sb[0],6,1) eq "1") { print(" Invalid OPcode !\n"); }
	if (substr($sb[0],7,1) eq "1") { print(" DATA Syntax error !\n"); }
	if (substr($sb[1],3,1) eq "1") { print(" MEMORY CORRUPT !\n"); }
	if (substr($sb[1],4,1) eq "1") { print(" Print Canceled !\n"); }
	if (substr($sb[1],5,1) eq "1") { print(" MEMORY Cleared !\n"); }
	if (substr($sb[1],6,1) eq "1") { print(" Command not allowed in current fiscal mode !\n"); }
	if (substr($sb[2],7,1) eq "1") { print(" NO PAPER !\n"); }
	if (substr($sb[4],2,1) eq "1") { print("MEMORY ERROR :\n"); }
	if (substr($sb[4],3,1) eq "1") { print(" Memory FULL !\n"); }
	if (substr($sb[5],5,1) eq "1") { print(" Unknown memory error !\n"); }
	if (substr($sb[5],7,1) eq "1") { print(" Memory is READONLY !\n"); }
# Misc and nonFatal Errors 
	if ($verbose) {
		if (substr($sb[0],4,1) eq "1") { print("Display pluged\n"); } else {print("No display plugged!\n");}
		if (substr($sb[0],5,1) eq "1") { print("Clock is not set!\n"); } else {print("Clock is set\n");}
		if (substr($sb[1],7,1) eq "1") { print("Cash Overflow ! Reduce !\n"); }
		if (substr($sb[2],2,1) eq "1") { print("Nonfiscal BON opened !\n"); }
		if (substr($sb[2],4,1) eq "1") { print("Fiscal BON opened !\n"); }
		if (substr($sb[3],1,1) eq "1") { print("Switch 2.2 is ON\n"); } else {print("Switch 2.2 is OFF\n");}
		if (substr($sb[3],2,1) eq "1") { print("Switch 2.1 is ON\n"); } else {print("Switch 2.2 is OFF\n");}
		if (substr($sb[3],3,1) eq "1") { print("Switch 1.5 is ON\n"); } else {print("Switch 1.5 is OFF\n");}
		if (substr($sb[3],4,1) eq "1") { print("Switch 1.4 is ON\n"); } else {print("Switch 1.4 is OFF\n");}
		if (substr($sb[3],5,1) eq "1") { print("Switch 1.3 is ON\n"); } else {print("Switch 1.3 is OFF\n");}
		if (substr($sb[3],6,1) eq "1") { print("Switch 1.2 is ON\n"); } else {print("Switch 1.2 is OFF\n");}
		if (substr($sb[3],7,1) eq "1") { print("Switch 1.1 is ON\n"); } else {print("Switch 1.1 is OFF\n");}
		if (substr($sb[4],4,1) eq "1") { print("Less than 50 units of memory remain !\n"); }
		if (substr($sb[4],5,1) eq "1") { print("NO FISCAL MEMORY !\n"); }
		if (substr($sb[4],7,1) eq "1") { print("Memory write error !\n"); }
		if (substr($sb[5],2,1) eq "1") { print("Memory and fiscal data set !\n"); } else { print("Memory and fiscal data are NOT set !\n"); }
		if (substr($sb[5],3,1) eq "1") { print("Tax groups set !\n"); } else { print("Tax groups are NOT set !\n"); }
		if (substr($sb[5],4,1) eq "1") { print("Printer is in fiscal mode !\n"); } else { print("Printer is NOT in fiscal mode !\n"); }
		if (substr($sb[5],6,1) eq "1") { print("Fiscal memory is cleared !\n"); }
	}
}

$#ARGV > -1 || die "\n...some arguments missing !\n\nusage :\n\nfiscalprn.pl [-v] command [data]\n\nExample:\nfiscalprn.pl -v setclock \"DD-MM-YY HH:MM:SS\"\nfiscalprn.pl -v openfiscal\nfiscalprn.pl -v add \"Apples\" \"A\" \"10.00\"\nfiscalprn.pl -v add \"Pears\" \"B\" \"10.00\"\nfiscalprn.pl -v total\nfiscalprn.pl -v closefiscal\nfiscalprn.pl -v newline\n\n";
# ok, all there, now let's interpret it !
my @cmdline = @ARGV;
if ($cmdline[0] eq "-v") {
	$verbose = 1;
	shift @cmdline;
	if ($#cmdline == -1) {die "\nWhat to verbose ?\n"};
}

my $command = shift(@cmdline);

# Initialize the fiscal printer
my $prn = Device::SerialPort->new ($port) || die "Cannot open $port !";
$prn->baudrate(9600);
$prn->parity("none");
$prn->databits(8);
$prn->stopbits(1);
$prn->handshake("none");
$prn->write_settings || die "Cannot setup printer !?";

my $enccmd = &encode (chr(0x20), chr(0x4a), "");
my $pass = $prn->write($enccmd) || die "Cannot communicate with Fiscal printer !";
sleep 1;
&prn_reply($prn->input);

if ($command eq "openfiscal") {
# data format is ,,[,]
# where Operator, password & OperatorPlace are preset index
# and I means that current Bon is treated as Invoice
	$enccmd = &encode (chr(0x21), chr(0x30), "1,0000,1");
	$pass = $prn->write($enccmd) || die "Cannot communicate with Fiscal printer !";
	sleep 1;
	&prn_reply($prn->input);
}

if ($command eq "newline") {
# data format []
	$enccmd = &encode (chr(0x21), chr(0x2c), shift(@cmdline));
	$pass = $prn->write($enccmd) || die "Cannot communicate with Fiscal printer !";
	sleep 1;
	&prn_reply($prn->input);
}

if ($command eq "add") {
# data format [][]<[sign]price>[*][,perc]
# text1 and text2 are both limited to 25 chars. 
	if ($#cmdline != 2) {die "\nNot enough arguments for invoice line !\n\n format is \n"}
	$enccmd = &encode (chr(0x21), chr(0x31), shift(@cmdline).chr(0x09).shift(@cmdline).shift(@cmdline));
	$pass = $prn->write($enccmd) || die "Cannot communicate with Fiscal printer !";
	sleep 1;
	&prn_reply($prn->input);
}

if ($command eq "total") {
# data format is [][][[Paidmode]<[sign]amount>]
	$enccmd = &encode (chr(0x21), chr(0x35), chr(0x09));
	$pass = $prn->write($enccmd) || die "Cannot communicate with Fiscal printer !";
	sleep 1;
	&prn_reply($prn->input);
}

if ($command eq "closefiscal") {
# no data
	$enccmd = &encode (chr(0x21), chr(0x38), "");
	$pass = $prn->write($enccmd) || die "Cannot communicate with Fiscal printer !";
	sleep 1;
	&prn_reply($prn->input);
}

if ($command eq "setclock") {
# no data
	$enccmd = &encode (chr(0x21), chr(0x3d), shift(@cmdline));
	$pass = $prn->write($enccmd) || die "Cannot communicate with Fiscal printer !";
	sleep 1;
	&prn_reply($prn->input);
}

# Close printer handle
sleep 1;
undef $prn;

__END__

=head1 NAME

fiscalprn - a CLI program for printing invoices with Datecs FP3530

=head1 SYNOPSIS

usage :

fiscalprn.pl [-v] command [data]

Example:
fiscalprn.pl -v setclock "DD-MM-YY HH:MM:SS"
fiscalprn.pl -v openfiscal
fiscalprn.pl -v add "Apples" "B" "10.00"
fiscalprn.pl -v add "Pears" "B" "10.00"
fiscalprn.pl -v total
fiscalprn.pl -v closefiscal
fiscalprn.pl -v newline

=head1 DESCRIPTION

fiscalprn.pl - a CLI program for printing invoices with Datecs FP3530

=head1 SEE ALSO

Need a symlink to your serial port named /dev/FP3530 and the Perl module Device::SerialPort

=head1 AUTHOR

 Stoill Barzakov

=cut
 Posted by at 2:07 pm

Mish-mash (миш-маш)

 My k1tch3n  Comments Off on Mish-mash (миш-маш)
Aug 152011
 
Mish mash

Mish mash (миш маш)

This dish sounds like someone has mismatched something and looks like a puke but is tasty 😀

It goes well with beers or wines. Can be served hot or cold, does not matter. Some prefer it hot, some prefer it cold. When cold, it’s a bit more spicy, because the liquid part becomes a bit harder and all the spices and flavors are mixed well.

Anyway. The picture has nothing to do with the taste 😛

Ingredients.

(for 4 serving)

6 eggs

500 grams (~1 pound) of salty cottage cheese

2 large tomatoes

4 green peppers

chunk of butter

some parsley.

Wooden spoon or spatula.

Preparation.

Break the 6 eggs and put them aside. Don’t stir. Clean the vegetables, peel the tomatoes, remove the seeds from the peppers. Put the chunk of butter in deep cooking pan or bowl, put it on the hot plate set to medium. Let the butter melt while you dice all the vegetables. Put the tomatoes first and cover with the lid for 15 minutes to steam them good then add the peppers. Stir a bit so they mix. Another 10-15 minutes with covered lid while you dice the cheese. Add the cheese and stir again thoroughly. Let all the vegetables be covered with white film from the cheese. Stir until the cheese becomes soft and creamy. Add the eggs and start stirring until the eggs are ready. It takes 5 to 8 minutes. The result should be a good mixed mash as in the picture above with vegetable dices inside.

Serve in 4 medium dishes with a toasted bread for dipping in. Cover with dozen  freshly sliced parsley leaves.

Bon appetite and cheers 😉

 

 Posted by at 11:11 am