[GTER] Display ServerU

Cleber A. Nascimento cleber at bsd.com.br
Mon Feb 1 21:00:20 -02 2016


Testarei em um ServerU logo ali.

Obrigado Patrick!!

2016-02-01 19:06 GMT-03:00 Rodrigo Meireles <mikrotikfull at gmail.com>:

> Patrick obrigado pela aula!!!
> TOP
>
> 2016-02-01 18:49 GMT-03:00 Patrick Tracanelli <eksffa at freebsdbrasil.com.br
> >:
>
> > Exatamente, o primeiro passo é como o Alexandre mencionou, ter o device.
> > Tanto LCM, keypad quanto controle programável de bypass vão precisar de
> > modulos complementares.
> >
> > Ja passou dessa fase? Os downloads dos módulos de kernel tanto pro
> display
> > quanto do keypad em:
> >
> > http://main.mia.serveru.us/pub/l/ServerU/plcm/
> >
> > Voce precisa compilar para a mesma versão de kernel do VyOS, uma vez
> > passando essa fase basta scriptar ou programar.
> >
> > O pacote tem 2 demos escritos em C que permitem manipular, e o próprio
> > utility que voce pode usar via shell script mesmo.
> >
> > Prepare o ambiente com mesma glibc e kernel e envie o modulo pra la. O
> > pacote ja vem com modulo compilado mas sabe como é, o ideal é vc sempre
> > compilar vc mesmo. Se tiver problemas abra um ticket conosco :-)
> >
> >
> >
> http://support.serveru.us/index.php?/ServerU/Knowledgebase/Article/View/62/0/how-to-control-serveru-plcm-device-your-self
> >
> >
> http://support.serveru.us/index.php?/ServerU/Knowledgebase/Article/View/74/0/controle-das-interfaces-bypass-no-serveru
> >
> > Temos alguns usuarios de Linux que reportaram sucesso ao usar também o
> > lcdproc quanto utility quanto daemon, ja que ele suporta uma gama de LCDs
> > de 2 linhas em porta paralela, serial e UART. Mas o que recomendamos é o
> > driver acima e fazer acesso direto pela utility adequada.
> >
> > Seguem samples.
> >
> >
> > /*
> >  * ServerU PLCM Utility
> >  *
> >  * ServerU - http://www.ServerU.com.br http://www.ServerU.us
> >  * PLCM with 2 lines with 4 keys pad model Netmap L100 & Netmap L800
> >  *
> >  * Developed and teste for/on FreeBSD RELENG_8, RELENG_9, RELENG_10
> >  * Ported and tested on Linux 2.4, Linux 2.6, Linux 3.0, 3.1 and 3.2
> >  *
> >  * Porting Notes: parei de usar a &plcm e passei a mandar o (int) direto;
> >  * os valores dos botoes do keypad sao diferentes tambem o retorno do
> >  * hardware;
> >  *
> >  *
> >  */
> >
> > #include <sys/file.h>
> > #include <stdio.h>
> > #include <string.h>
> > //#include "serveru-plcm-util.h"
> > #include "../serveru-plcm-util.h"
> >
> > int main(int argc,char *argv[])
> > {
> >         int devfd;
> >         unsigned char tmp_str[20];
> >
> >         if (argc < 2) {
> >          printf("Erro! Exemplo de uso:\n %s \"Valor na PLCM1...\" \"Valor
> > na PLCM2...\"\n",argv[0]);
> >          return(1);
> >         }
> >
> >
> >         iopl(3);
> >         printf("ServerU PCL Test Sample - Write @LCM1 and @LCM2\n");
> >         devfd = open("/dev/plcm_drv",O_RDWR);
> >         if( devfd == -1 )
> >         {
> >                 printf("Can not open /dev/plcm_drv\n");
> >                 return -1;
> >         }
> >         ioctl(devfd,PLCM_IOCTL_CLEARDISPLAY,0);
> >         //show input string
> >         printf("Input1: %s\n",argv[1]);
> >         printf("Input2: %s\n",argv[2]);
> >         memset(tmp_str,0,20);
> >         strcpy(tmp_str,argv[1]);
> >         ioctl(devfd,PLCM_IOCTL_SET_LINE,1);
> >         write(devfd,tmp_str,20);
> >         memset(tmp_str,0,20);
> >         strcpy(tmp_str,argv[2]);
> >         ioctl(devfd,PLCM_IOCTL_SET_LINE,2);
> >         write(devfd,tmp_str,20);
> >
> >         close(devfd);
> >         return 0;
> > }
> >
> >
> > #!/bin/sh
> > #
> > # ServerU PLCM Utility
> > #
> > # ServerU - http://www.ServerU.com.br http://www.ServerU.us
> > # PLCM with 2 lines with 4 keys pad model Netmap L100 & Netmap L800
> > #
> > # Example useless shell script
> > #
> > # Remember LCM display 1 and 2 has 21 chars limit.
> > #
> >  ./serveru-plcm-util -LCM1
> >  /bin/echo -n "Attention! Important!" > /dev/plcm_drv
> >  ./serveru-plcm-util -LCM2
> >  /bin/echo -n "This is just a test. " > /dev/plcm_drv
> >
> > count=20
> >
> > while [ $count -gt 0 ] ; do
> >  ./serveru-plcm-util -Off
> >  sleep 0.3
> >  ./serveru-plcm-util -On
> >  sleep 0.3
> >  count=$(( $count -1 ))
> > done
> >
> >  ./serveru-plcm-util -On
> >
> > /*
> >  * ServerU PLCM Utility
> >  *
> >  * ServerU - http://www.ServerU.com.br http://www.ServerU.us
> >  * PLCM with 2 lines with 4 keys pad model Netmap L100 & Netmap L800
> >  *
> >  * Developed and teste for/on FreeBSD RELENG_8, RELENG_9, RELENG_10
> >  * Ported and tested on Linux 2.4, Linux 2.6, Linux 3.0, 3.1 and 3.2
> >  *
> >  * Porting Notes: parei de usar a &plcm e passei a mandar o (int) direto;
> >  * os valores dos botoes do keypad sao diferentes tambem o retorno do
> >  * hardware;
> >  *
> >  *
> >  */
> > #include <sys/types.h>
> > #include <sys/ioctl.h>
> > #include <sys/file.h>
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <string.h>
> > #include <fcntl.h>
> > #include <unistd.h>
> > #include <err.h>
> > #include "serveru-plcm-util.h"
> >
> > int usage(int devfd) {
> >   printf("Comando Invalido\n");
> >   printf("Uso: serveru-plcm-util
> >
> [-stop|-On|-Off|-DispOff|-DispOn|-LCM1|-LCM2|-Keypad|-Read1|-Read2|-Clear]\n");
> >   printf("ServerU LCM Utility by ServerU Inc\n");
> >   close(devfd);
> >   return 0;
> > }
> >
> > int main(int argc, char *argv[])
> > {
> >         struct _plcm plcm;
> >         int devfd;
> >         unsigned char Ret_Message1[40] = "";
> >         unsigned char Ret_Message2[40] = "";
> >         int i = 0;
> >         unsigned char Keypad_Value = 0, Pre_Value = 0, Counter = 0;
> >         unsigned char Keypad_Message[40] = "";
> >         unsigned char Up[]    = "Up   ";
> >         unsigned char Down[]  = "Down ";
> >         unsigned char Left[]  = "Left ";
> >         unsigned char Right[] = "Right";
> >         unsigned char detect_press;
> >         unsigned char detect_dir;
> >         int MaxTestTime = 1 ; // 15 Sec
> >
> >         devfd = open("/dev/plcm_drv", O_RDWR);
> >         if(devfd == -1)
> >         {
> >                 printf("Cant open: /dev/plcm_drv\n");
> >                 return -1;
> >         }
> >         if(argc == 2)
> >         {
> >                 // Inicializa Defaults ServerU
> >                 Keypad_Message[40] = "";
> >                 plcm.amg=0;
> >                 ioctl(devfd, PLCM_IOCTL_DISPLAY_B, 0); // desliga blink
> >                 ioctl(devfd, PLCM_IOCTL_DISPLAY_C, 0);
> >
> >                 if(strcmp("-stop", argv[1]) == 0)
> >                 {
> >                     plcm.amg=0;
> >                         ioctl(devfd, PLCM_IOCTL_STOP_THREAD, 0);
> >                         printf("plcm_drv stopped.\n");
> >                         close(devfd);
> >                         return 0;
> >                 }
> >                 if(strcmp("-On", argv[1]) == 0)
> >                 {
> >                         plcm.amg=1;
> >                         ioctl(devfd, PLCM_IOCTL_BACKLIGHT, 1);
> >                         close(devfd);
> >                         return 0;
> >                 }
> >                 if(strcmp("-Off", argv[1]) == 0)
> >                 {
> >                         plcm.amg=0;
> >                         ioctl(devfd, PLCM_IOCTL_BACKLIGHT, 0);
> >                         close(devfd);
> >                         return 0;
> >                 }
> >                 if(strcmp("-LCM1", argv[1]) == 0)
> >                 {
> >                         plcm.amg=1;
> >                         ioctl(devfd, PLCM_IOCTL_SET_LINE, 1);
> >                         close(devfd);
> >                         return 0;
> >                 }
> >                 if(strcmp("-LCM2", argv[1]) == 0)
> >                 {
> >
> >                         plcm.amg=2;
> >                         ioctl(devfd, PLCM_IOCTL_SET_LINE, 2);
> >                         close(devfd);
> >                         return 0;
> >                 }
> >                 if(strcmp("-Keypad", argv[1]) == 0)
> >                 {
> >                         Keypad_Message[40] = "";
> >                         plcm.amg=1;
> >                         ioctl(devfd, PLCM_IOCTL_SET_LINE, 1);
> >                         do{
> >                                 plcm.amg=0;
> >                                 //ioctl(devfd, PLCM_IOCTL_GET_KEYPAD,
> > &plcm);
> >                                 ioctl(devfd, PLCM_IOCTL_GET_KEYPAD, 0);
> //
> > Linux
> >                                 //Keypad_Value=plcm.key_value;
> >                                 Keypad_Value=ioctl(devfd,
> > PLCM_IOCTL_GET_KEYPAD, 0); // Linux
> >                                 detect_press=(Keypad_Value & 0x40);
> >                                 detect_dir=(Keypad_Value & 0x28);
> >                                 switch(detect_dir)
> >                                 {
> >                                         case 0x00:
> >
> > strcpy(Keypad_Message,"2-");
> >                                                 break;
> >                                         case 0x20:
> >
> > strcpy(Keypad_Message,"1-");
> >                                                 break;
> >                                         case 0x08:
> >
> > strcpy(Keypad_Message,"3-");
> >                                                 break;
> >                                         case 0x28:
> >
> > strcpy(Keypad_Message,"4-");
> >                                                 break;
> >
> >                                 // Mas no Linux os valores podem ser
> outros
> >                                 /*
> >                                         case 0xC7:
> >                                                 strcpy(Keypad_Message,
> > "1-");
> >                                                 break;
> >                                         case 0xE7:
> >                                                 strcpy(Keypad_Message,
> > "2-");
> >                                                 break;
> >                                         case 0xEF:
> >                                                 strcpy(Keypad_Message,
> > "3-");
> >                                                 break;
> >                                         case 0xCF:
> >                                                 strcpy(Keypad_Message,
> > "4-");
> >                                                 break;
> >                                  */
> >                                 }
> >                                 switch(detect_press)
> >                                 {
> >                                         // Press e Release funcional
> igual
> > no FreeBSD e Linux
> >                                         case 0x40:
> >
> > strcat(Keypad_Message,"Press  ");
> >                                         case 0x00:
> >
> > strcat(Keypad_Message,"Release");
> >                                 }
> >
> > //printf("Value:%x:%s\n",plcm.key_value,Keypad_Message);
> >
> > printf("Value:%x:%s\n",Keypad_Value,Keypad_Message);
> >
> >                                 plcm.amg=0;
> >                                 //write(devfd, Keypad_Message, 40);
> >                                 Pre_Value = Keypad_Value;
> >                                 MaxTestTime--;
> >                                 if(MaxTestTime == 0)
> >                                 {
> >                                         break;
> >                                 }
> >                         }while(1);
> >                         close(devfd);
> >                         return 0;
> >                 }
> >                 if(strcmp("-DispOff", argv[1]) == 0)
> >                 {
> >                         plcm.amg=0;
> >                         ioctl(devfd, PLCM_IOCTL_DISPLAY_D, 0);
> >                         close(devfd);
> >                         return 0;
> >
> >                 }
> >                 if(strcmp("-DispOn", argv[1]) == 0)
> >                 {
> >                         plcm.amg=1;
> >                         ioctl(devfd, PLCM_IOCTL_DISPLAY_D, 1);
> >                         close(devfd);
> >                         return 0;
> >
> >                 }
> >                 if(strcmp("-Read1", argv[1]) == 0)
> >                 {
> >                         plcm.amg=2;
> >                         ioctl(devfd, PLCM_IOCTL_SET_LINE, 2);
> >                         read(devfd, Ret_Message1, sizeof(Ret_Message1));
> >                         printf("Read LCM1: %s\n", Ret_Message1);
> >                         close(devfd);
> >                         return 0;
> >                 }
> >                 if(strcmp("-Read2", argv[1]) == 0)
> >                 {
> >                         plcm.amg=2;
> >                         ioctl(devfd, PLCM_IOCTL_SET_LINE, 2);
> >                         read(devfd, Ret_Message2, sizeof(Ret_Message2));
> >                         printf("Read LCM2: %s\n", Ret_Message2);
> >                         close(devfd);
> >                         return 0;
> >                 }
> >                 if(strcmp("-Clear", argv[1]) == 0)
> >                 {
> >                         plcm.amg=0;
> >                         ioctl(devfd, PLCM_IOCTL_CLEARDISPLAY, 0);
> >                         plcm.amg=0;
> >                         ioctl(devfd, PLCM_IOCTL_RETURNHOME, 0);
> >                         close(devfd); return 0;
> >                 }
> >
> >                 usage(devfd); return 0;
> >         }
> >         usage(devfd);
> > }
> >
> >
> >
> >
> >
> >
> > > On 01/02/2016, at 15:47, Alexandre J. Correa (Onda) <
> > alexandre at onda.net.br> wrote:
> > >
> > > http://www.serveru.us/pt/doc/lcm-util
> > >
> > > ele tem um device no /dev para gerenciar isto, no site acima fala mais
> > sobre...
> > >
> > > se o kernel não estiver com o driver, precisa carregar/instalar para
> ter
> > acesso.
> > >
> > >
> > > Em 01/02/2016 13:31, Rafael Galdino escreveu:
> > >> Boa tarde srs.
> > >>
> > >> alguém já colocou o serverU para mostrar CPU, Banda etc... no display
> > >> utilizando o Vyos?
> > >> --
> > >> gter list    https://eng.registro.br/mailman/listinfo/gter
> > >
> > >
> > > --
> > > Sds.
> > >
> > > Alexandre Jeronimo Correa
> > > Sócio-Administrador
> > >
> > > Office: +55 34 3351 3077
> > >
> > > Onda Internet
> > > www.onda.net.br
> > >
> > > --
> > > gter list    https://eng.registro.br/mailman/listinfo/gter
> >
> > --
> > Patrick Tracanelli
> >
> > FreeBSD Brasil LTDA.
> > Tel.: (31) 3516-0800
> > 316601 at sip.freebsdbrasil.com.br
> > http://www.freebsdbrasil.com.br
> > "Long live Hanin Elias, Kim Deal!"
> >
> > --
> > gter list    https://eng.registro.br/mailman/listinfo/gter
> >
>
>
>
> --
> *Rodrigo Melo Meireles*
>
> *CTO - Solustic Solucoes em Tecnologia-TI*
> Analista/Consultor de Redes
> Analista de Segurança
> Mikrotik Certified
> URBSS Certified
> 85.40629515 85.996459346
> --
> gter list    https://eng.registro.br/mailman/listinfo/gter
>



-- 

Cleber Alves

.ılı..ılı.
"Observe as estrelas e aprenda com elas." Albert Einstein



More information about the gter mailing list