LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 03-01-2011, 09:09 AM   #1
toredo
Member
 
Registered: Feb 2009
Posts: 83

Rep: Reputation: 25
LCD UDB Edition 1 / DE-LD011


Hello,

I bought a "LCD Display USB (Edition 1)". I can use this very simple device over USB.

Linux says me, that the device is a "cp210x" usb2serial-device. That's ok. "cp210x" creates me the device "/dev/ttyUSB0". This device, i think, should be used to program the LCD.

I searched and i searched, but i didn't find a needable software to program the device. May the communication is no standart? But, no problem, there are only a few commands. They're descripted in a pdf:
http://www.sure-electronics.net/down..._Ver1.0_EN.pdf

For example:
0xFE 0x46 Should turn the backlight off.
0xFE 0x42 0x00 Should turn the backlight on.
0xFE 0x98 0x[01-FE] Should define the the brightness of the LCD.

There are a few other commands. But the only one that works for me is the command to turn the backlight off. Why?

All the other commands do nothing... May be i make something wrong. Or there's a software for this board?

I use this code to configure the LCD:
Code:
//
//DislayTest.cpp
//
#include <termios.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/signal.h>
#include <sys/types.h>

#define BAUDRATE B9600
#define device "/dev/ttyUSB0"
unsigned char ClearScreen[] = {254,88};
unsigned char backoff[] = { 0xFE, 0x46
//'a', 'b', 'c', 'd',
//'e', 'f', 'g', 'h',
//'i', 'j', 'k', 'l'
 };
unsigned char WelcomeMessage[] = {'H','e','l','l','o',' ','W','o','r','l','d','!'};

int main(int argc, char *argv[])
{
       struct termios term;
       //Open the serial port
       int lcd = open(device, O_RDWR | O_NOCTTY | O_NONBLOCK);

       //handle errors
       if (lcd < 0)
       {
               printf("Error opening serial port %s\n",device);
               return -1;
       }

       //Setup the serial port 8 data bits, no parity ,1 stopbit, no flow control
       term.c_cflag = BAUDRATE | CS8 | CSTOPB | CLOCAL | CREAD;
       term.c_iflag = 0;
       term.c_oflag = 0;
       term.c_lflag = 0;
       tcflush(lcd, TCIFLUSH);
       tcsetattr(lcd,TCSANOW,&term);

       //Write Welcome Message to the display
       //write(lcd,ClearScreen,sizeof(ClearScreen));
       //write(lcd,WelcomeMessage,sizeof(WelcomeMessage));
	write(lcd, backoff, sizeof(backoff));

       //Close the display
       close(lcd);
       return 0;
}
Thanks,

best regards
toredo

-edit-

I listend on my windows machine with the tool portmon the serial port with the device. Then i used LCD Smartie to work with the device. The communication looks ok.

After this i tried to write a c#-tool for the device:
Code:
SerialPort sp = new SerialPort("COM24");
sp.BaudRate = 9600;
sp.StopBits = StopBits.One;
sp.DataBits = 8;
sp.Open();
foreach (int n in Enumerable.Range(1, 254))
{
    sp.Write(new byte[] { 0xFE, 0x98, (byte)n }, 0, 3);
    Thread.Sleep(10);
}
sp.Close();
It works perfeclty! It's very simple and stupid. It makes the background light in litle steps haler. all other commands work too.

But, i tried this to write in Perl or C. but it never worked? As base i used to C-Code upside. For Perl i used Device::SerialPort.

May my parameters are bad?

Has anyone an idea?

best regards
toredo

Last edited by toredo; 03-02-2011 at 08:25 AM.
 
Old 03-03-2011, 07:57 AM   #2
toredo
Member
 
Registered: Feb 2009
Posts: 83

Original Poster
Rep: Reputation: 25
Hello,

I wrote a tool to test many things in C#. It works correctly on windows. With the same tool on linux only some commands work, but not all work.

Why?
I grabbed the needed settings with portmon. Firstly are the settings and then my test-binary-data, which should show on the display in the row 1 "3333333333333333".

Screenshot:
http://img607.imageshack.us/img607/9494/rs232.png

I tried to code this in Perl (Device::SerialPort), C# (SerialPort-Class) and C on linux. But nothing runs ok...

It there a way to log the data which goes over the /dev/ttyUSB0?
Or can someone show me a code which defines these settings?

thank,
best regards
toredo

Last edited by toredo; 03-03-2011 at 08:17 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Which edition (desktop edition or Server edition) best for Oracle RAC on vm thmsvng Linux - Virtualization and Cloud 2 11-26-2009 04:13 PM
Syntax (in Linux) for isql to connect to UDB. krishna.natesh Linux - Newbie 0 08-27-2008 02:24 AM
LXer: Accessing DB2 UDB with PHP (Part 2) LXer Syndicated Linux News 0 08-10-2006 07:21 AM
LXer: Accessing DB2 UDB with PHP LXer Syndicated Linux News 0 08-07-2006 04:33 PM
RedHat Alpha on Multia/UDB TotalDefiance Linux - Hardware 1 07-20-2005 12:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 05:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration