News:

LATEST RELEASE:  FPP 6.3 - Download from here - https://github.com/FalconChristmas/fpp/releases/tag/6.3

+-+-

+-User

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+-Site Stats

Members
Total Members: 15659
Latest: PaulDzRGB
New This Month: 9
New This Week: 3
New Today: 1
Stats
Total Posts: 128431
Total Topics: 15791
Most Online Today: 68
Most Online Ever: 7634
(January 21, 2020, 02:14:03 AM)
Users Online
Members: 4
Guests: 31
Total: 35

Serial output

Started by gdyrdave, September 17, 2014, 08:24:07 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gdyrdave

 Would this be a viable idea? Connect a serial dongle to a usb port and issue a serial (hex) command to a projector ie: on/off via script. This might help some that have rs232 control over their projectors. Just another of my cockamammy thoughts again.

Materdaddy

Shouldn't be too difficult.

Instead of configuring FPPD to use /dev/ttyUSBX (where X is the 0-based number of the dongle) for Renard, DMX, etc. somebody could write a script/program that uses the dongle.

Do you know what kind of data needs to be sent to such a projector?

gdyrdave

Yup. Here tis:

• Control command Syntax (From PC to Projector)
[H][AC][SoP][CRC][ID][SoM][COMMAND]
• Example: power on the projector
Enter the following code: 0xBE 0xEF 0x10 0x05 0x00 0xC6 0xFF 0x11
0x11 0x01 0x00 0x01
NOTE: Send least significant bytes first.

Or off:

• Control command Syntax (From PC to Projector)
[H][AC][SoP][CRC][ID][SoM][COMMAND]
• Example: power on the projector
Enter the following code: 0xBE 0xEF 0x10 0x05 0x00 0x03 0x3E 0x11
0x11 0x01 0x00 0x18
NOTE: Send least significant bytes first.

Its at 19200,8,n,1.

Materdaddy

You might get away with something like this to turn on:


#!/bin/bash

stty -F /dev/ttyUSB0 speed 19200 cs8 -cstopb -parenb
echo -en '\xBE\xEF\x10\x05\x00\xC6\xFF\x11\x11\x01\x00\x01' > /dev/ttyUSB0


And off:

#!/bin/bash

stty -F /dev/ttyUSB0 speed 19200 cs8 -cstopb -parenb
echo -en '\xBE\xEF\x10\x05\x00\x03\x3E\x11\x11\x01\x00\x18' > /dev/ttyUSB0


Or wrap it in a conditional so you can tell the script off or on:

#!/bin/bash

stty -F /dev/ttyUSB0 speed 19200 cs8 -cstopb -parenb

case $1 in
  on|ON|On)
    echo -en '\xBE\xEF\x10\x05\x00\xC6\xFF\x11\x11\x01\x00\x01' > /dev/ttyUSB0
    ;;
  off|OFF|Off)
    echo -en '\xBE\xEF\x10\x05\x00\x03\x3E\x11\x11\x01\x00\x18' > /dev/ttyUSB0
    ;;
  *)
    echo "Error, need argument of On/Off" >&2
    exit 1
    ;;
esac

gdyrdave

Will that work on a generic rs232 usb converter? I have an older Radio Snack one. I will give that a shot anyway. Thanks Mat.

CaptainMurdoch

If that doesn't work, I have some Perl code I can post.  I gave it to Pat as an example a while back to control his external HDMI switcher.  It does pretty much the same thing as the bash script but uses Device::SerialPort to setup the serial port.
-
Chris

gdyrdave

Chris, is that the serial port on board the pi or an external Usb device. not that it matters, I'll just have to do some signal conditioning between the pi and projector. Either way would like to see your code too.

CaptainMurdoch

He used a USB serial dongle with the perl script.  I will post tonight after I dig it up.
-
Chris

gdyrdave


gdyrdave

Mat, is that a python script or something else. I would like to explore different script languages. You guys have other more grander priorities than to teach me script. So do I but my mind is racing like a Nascar....lol

Materdaddy

It's a bash script.  The first line of scripts in linux (often called the "shebang" for the #!) tells the shell which interpreter to use for the script.

To write a shell script, you typically start with "#!/bin/sh", or if you want to use bourne again shell (more options, newer, etc.) you'd use /bin/bash for the interpreter.

Usually for python scripts, they'd start with "#!/usr/bin/env python" which starts the default python interpreter for the script.

In addition, I'd probably attach python scripts instead of having them in-line in posts because they don't use brackets and keywords for code blocks, they use indentation, so any copy/pasting (especially when somebody's using windows) would create tons of problems.

Hope that helps.  If you have other questions, post up and we can point you at some links.

EDIT:
Potentially helpful links:
http://en.wikipedia.org/wiki/Shebang_(Unix)
http://linuxcommand.org/writing_shell_scripts.php
http://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-first-line-of-a-python-script

CaptainMurdoch

Here is the hack perl script that I threw together for Pat to control his HDMI switcher via the serial port.  It could use a little cleanup and could be done differently.  Instead of putting the hex characters in a string and writing the string, I put them in an array of arrays.  The command line parameter is used as the index into the main associative array.  The value of that element is an indexed array of the values that need to be written.  If someone wants to clean this up, add comments, etc., and make it more generic as an example, we could put it in the new script repository that is now browsable in v0.4.0.


#!/usr/bin/perl
####################
# Device::SerialPort must be installed first, on the PI, this can be done via "sudo apt-get install libdevice-serialport-perl"
####################
use Device::SerialPort;

my $port = "/dev/ttyUSB0";  # change to /dev/ttyS0 if on a real DB9 serial port
my $hexCodes = {
    "1" => [0x20, 0x02, 0x01, 0x01, 0xA5, 0x20, 0x08, 0x01, 0x00, 0x91, 0x20, 0x01, 0x01, 0x01, 0x41, 0x20, 0x07, 0x01, 0x00, 0xCE],
    "2" => [0x20, 0x02, 0x01, 0x02, 0x47, 0x20, 0x08, 0x01, 0x00, 0x91, 0x20, 0x01, 0x01, 0x02, 0xA3, 0x20, 0x07, 0x01, 0x00, 0xCE],
    "3" => [0x20, 0x02, 0x01, 0x03, 0x19, 0x20, 0x08, 0x01, 0x00, 0x91, 0x20, 0x01, 0x01, 0x03, 0xFD, 0x20, 0x07, 0x01, 0x00, 0xCE],
    "4" => [0x20, 0x02, 0x01, 0x04, 0x9A, 0x20, 0x08, 0x01, 0x00, 0x91, 0x20, 0x01, 0x01, 0x04, 0x7E, 0x20, 0x07, 0x01, 0x00, 0xCE],
    };

my $input = "1";
if ((defined($ARGV[0])) && (defined($hexCodes->{$ARGV[0]}))) {
    $input = $ARGV[0];
}

my $codes = $hexCodes->{$input};
my $port = new Device::SerialPort($port) || die "Can't open $port: $!";;

$port->user_msg(ON);
$port->baudrate(9600);
$port->parity("none");
$port->databits(8);
$port->stopbits(1);
$port->handshake("xoff");
$port->write_settings;
$port->lookclear;

foreach my $code (@{$codes}) {
    $port->write(chr($code));
}
-
Chris

Support FPP

+- Recent Topics

Warning/Error: Network incomplete frames hit 250. by JonD
Today at 04:10:22 PM

F16V3 with 2 expansion boards at 40 fps MAX PIXELS per output? by tbone321
Today at 10:51:55 AM

F48V4-NS at 40 fps using all 48 pixel output ports? by Poporacer
Today at 10:27:09 AM

Unable to update RPi 5.5 to latest version by JonB256
February 05, 2023, 07:23:16 PM

help getting started, next step? by rayster
February 05, 2023, 04:24:09 PM

F48v4NS - Pi or No Pi? by joeyblasko
February 05, 2023, 09:15:33 AM

Huidu Controllers LED matrix by CaptainMurdoch
February 04, 2023, 10:18:47 AM

FPP6.2 universes by darylc
February 03, 2023, 08:48:57 PM

F16v4 Ports vs Universe Configuration Question by k6ccc
February 03, 2023, 09:32:48 AM

Need Expert Advise on F16v4 Ports vs Universe Configuration by Kairus
February 03, 2023, 09:32:33 AM

Powered by EzPortal
Powered by SMFPacks Menu Editor Mod