Linux and perl problem

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

Post Reply
unstabl1
LCD?
Posts: 7
Joined: Thu Aug 29, 2002 6:00 pm
Location: ON, Canada

Linux and perl problem

Post by unstabl1 »

I'm having trouble sending the command codes to my display with perl. Everything seemed to be working fine until I re-did my system (wipe and re-install).
I found a bunch of examples and now they are not working.

here it an example...

open(LCD,">/dev/lcd")||die "ERROR: can not write to /dev/lcd\n";
$|=1;
my $i=0;
while(1){
$i++;
print LCD "\xFE",chr(0x58); # clear the display
print LCD "Count $i\n";
sleep(1);
}
close LCD;

Before runnuning the script, a c++ program is run to set the baud rate, turn on backlight, etc ... and it is working fine. With the script instead of clearing the screen, I get 2 weird chars, an X and the the Count # part.

System - RedHat 8.0 (was v7.3 when everything worked...)
Matrix Orbital BLK202A-4BR

This is my first experience with perl, so thanks for any help.

Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3014
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

I'm no perl expert, but I'll try. If you are getting the 'X' displayed on the LCD, that means the command prefix didn't work, meaneing it was not sent, or sent incorectly to the LCD. If the command prefix worked, the LCD would have been expecting a command and you would not have seen the 'X' on the LCD...
Henry J.
President
Matrix Orbital

Mat-Moo
LCD Guru
Posts: 502
Joined: Wed Jan 16, 2002 4:00 pm
Contact:

Post by Mat-Moo »

Or the baud rate is wrong on the port...

linear
evil Dr. linear
evil Dr. linear
Posts: 288
Joined: Wed Aug 15, 2001 6:00 pm
Location: USA
Contact:

Post by linear »

I'd try using the MOperl.zip perl module that Anders Bronworth wrote. It's really nice--it takes care of all that crap for you, while still being really lightweight and well-written.

At minimum, if you don't wanna use it, the way he handled commands is pretty slick (I thought anyhow).
BLK202A-4BR-BK + LK202-25-WB-V + LK204-25-V + VK204-25-V + LK-202-24-USB + MX212

ctimmer
LCD!
Posts: 15
Joined: Thu Oct 25, 2001 6:00 pm
Location: Alaska

Post by ctimmer »

Also check the tty settings (stty -a < /dev/lcd, I think) after the c++ application has run. The character size may be set to cs7. This would cause any character above x7F to be sent incorrectly.

unstabl1
LCD?
Posts: 7
Joined: Thu Aug 29, 2002 6:00 pm
Location: ON, Canada

Post by unstabl1 »

Thanks for the help. I checked the settings after the c++ app runs. It is set at cs8.
The MO-perl is nice. It almost works for me. For some reason, the display is still not being cleared if I use the text_example as is. The display does not clear, and I get an X at pos (1,1) and 'Hi there!' is displayed at (1,7). If I edit the script and add a display_clear after the init, all is well.
Is it possible that there could be some 'data' or something sitting in a buffer of sorts that is interfering? or another app I don't know about that is accessing my com port? I'm just guessing here and have no idea if this is plausible, but I have tried rearranging the order of the line in the display_init function:

print DISPLAY "$on$repeat$noblink$dim$clear";

and I am seeing different chars on the display eg, X or B and they seem to relate to the last value in the statement...
now it works. What the hell. I'm calling it a night. Again, any help or guidance is greatly appreciated.

ctimmer
LCD!
Posts: 15
Joined: Thu Oct 25, 2001 6:00 pm
Location: Alaska

Post by ctimmer »

One more thing to try, change the lcd open to:
open(LCD,">-")||die "ERROR: can not write to /dev/lcd\n";

This will cause the LDC output to go to stdout.

Run the test script capturing the output:
lcdtest.pl > lcd.out

Then, dump the output in hex:
od -h lcd.out # hex only
od -hc lcd.out # hex and character out

Check the output against the manual for validity on your LCD. You may find the output is not what you expected.

It sure would be nice if MO LCDs had a hex dump mode so you could see exactly what it is receiving. Henry???

Enjoy,
Curt

Post Reply