ArduinoGeneral

Where is a simple easy to manipulate software program to test the RLY-8-RS485

userHead Account cancelled 2019-03-17 04:12:10 2930 Views0 Replies
ref: RLY-8-RS485 8 Relay Controller SKU:DFR0290
as of 20190316 webpage is:
https://www.dfrobot.com/wiki/index.php/ ... FR0290#FAQ

I think this device is what I need, but its not clear how to determine if this will work.
This is what I need, I will need a lot of them but I need to know it will work properly before I put an engineer on the task of working with it.

The device I need is something that controls 8 relays so I can power up and down up to 8 LED's when I want to. As the LED's may be of different voltages I will need to send in the power on the (C) pin, and wire my LED to either the NC or NO pin based on what I want it to do. Pretty straight forward so far.

I want the device to be powered by the ethernet cable that I will attach to it, aka POE

My host computer should be able run a TCP/IP client program that sends and receives a TCP/IP message to this device and when I hook up my LED to a relay it should be able to be controlled by some of the commands of the TCP/IP client program running on some kind of computer, Linux, Windows, Mac, Arduino, PI, Beaglebone, etc. the program should be simple enough to run on ALL of these platforms.

Here is where I get into trouble with the documentation and description of this product, the webpage does not detail how I to do a SIMPLE acceptance test of the device to show functionality. Here is my issue.

I looked at the documentation and software specifically "RELY-8-POE-EN.PDF" and "RLY-8 software.rar" I was very excited when I read the PDF as I can see simple easy to understand TCP/IP command codes I could do to test the device. For example:

1.3 Relay Button Control Command Format
Return Value(data): 00 is success ; 01 is fail
Example: The host sends the device to control the number 1 relay to on or off:
55 AA 01 02 00 01 01 04 relay 1 off
55 AA 01 02 00 01 00 03 relay 1 on
Note: 1) Relay Number: 0x01-0x08. 2) Relay Values: 0x01 is closed, 0x00 is open.


Beautiful. I'm excited. I'm not sure how the checksum is calculated, but at least there are examples to test. I'm even more excited as I see the software is in ".rar" format so I'm expecting some nice linux program to test the device. Here is were all my hopes and dreams are shattered.

"RLY-8-softare.rar" is 98mb of bloatware nonsense where a 50-200 line c source file should be to send and receive TCP/IP messages should be. I have ZERO confidence in any of this. Where is a simple command line program where I type the command with some parameters such as an IP address, a port, and the program printf's a list of maybe a list of 10 commands to turn on and off relays so I can see that the device works? As a developer I need to see how to Programmatically send commands to this device, I need to see a simple C program (NOT VISUAL STUDIO!!!!!!) that is little more than filling static arrays with hex values that match EXACTLY to the command structure as detailed in RELY-8POE-EN.pdf (and a function to compute the checksum.). If the program is not self contained, and requires exactly ZERO dlls you did it wrong.

Does anybody have something like this or can it be created by someone who has this device in front of them? the whole thing should take about an hour. Thanks - jleslie48

P.S.
here's a link for a simple TCP client (and server, we don't care about the server for this exercise):

https://www.geeksforgeeks.org/tcp-serve ... tion-in-c/

the function "func" will need to be reworked to so that it has a list of commands to exercise the device
instead of asking the user to input a text string. Here I'll re-write "func" so that is toggles the relay 1 on and off
10 times before exiting the program. I'm not compiling it so it may not be exactly correct but its close. It's just an example.

specifically:
Code: Select all
// Compilation –
// Client side:
// gcc client.c -o client
// ./client

// Notes
// 190316  JL   copy from the web.   User will have to change the IP address and ports properly.
//                         command sent via "buff" in func is a direct copy from the example.    the last byte is a checksum 
//                         that I cannot explain how is calculated because of crappy documentation and no sample 
//                         code of how to do it is in the documentation


// Write CPP code here 
#include <netdb.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include <sys/socket.h> 
#define MAX 80 
#define PORT 8080 
#define SA struct sockaddr 

void func(int sockfd) 
{ 
        //190316   JL  rewrite of func so that is blinks relay 01 10 times in some 20 seconds. 

	char buff[MAX]; 
	int n; 
        int rbyte_count; 
	for (loop_counter=0; loop_counter < 10; loop_counter++) {
   
              // turn on relay 1 based on the document RELY-8-POE-EN.pdf, page 1, section 1.3
   		buff[0]=55;
                buff[1]=AA;
		buff[2]=55;
                buff[3]=01;
		buff[4]=02;
                buff[5]=00;
                buff[6]=01;
		buff[7]=01;
                buff[8]=04;
		
                write(sockfd, buff, 9); 
		bzero(buff, sizeof(buff)); 
		rbyte_count= read(sockfd, buff, sizeof(buff)); 
                 printf("on command: got %d characters back from the server\n",rbyte_count); 
		// some kind of hex dump code goes here to look at the buff

                sleep(1);  //sleep for a second. 


              // turn off relay 1 based on the document RELY-8-POE-EN.pdf, page 1, section 1.3
   		buff[0]=55;
                buff[1]=AA;
		buff[2]=55;
                buff[3]=01;
		buff[4]=02;
                buff[5]=00;
                buff[6]=01;
		buff[7]=00;
                buff[8]=03;
		
                write(sockfd, buff, 9); 
		bzero(buff, sizeof(buff)); 
		rbyte_count= read(sockfd, buff, sizeof(buff)); 
                 printf("off command: got %d characters back from the server\n",rbyte_count); 
		// some kind of hex dump code goes here to look at the buff

                sleep(1);  //sleep for a second. 
	} //for
} // function func

int main() 
{ 
	int sockfd, connfd; 
	struct sockaddr_in servaddr, cli; 

	// socket create and varification 
	sockfd = socket(AF_INET, SOCK_STREAM, 0); 
	if (sockfd == -1) { 
		printf("socket creation failed...\n"); 
		exit(0); 
	} 
	else
		printf("Socket successfully created..\n"); 
	bzero(&servaddr, sizeof(servaddr)); 

	// assign IP, PORT 
	servaddr.sin_family = AF_INET; 
	servaddr.sin_addr.s_addr = inet_addr("127.0.0.1"); 
	servaddr.sin_port = htons(PORT); 

	// connect the client socket to server socket 
	if (connect(sockfd, (SA*)&servaddr, sizeof(servaddr)) != 0) { 
		printf("connection with the server failed...\n"); 
		exit(0); 
	} 
	else
		printf("connected to the server..\n"); 

	// function for chat 
	func(sockfd); 

	// close the socket 
	close(sockfd); 
} //main
//eof