Solved

how to access a card modicon pci-85 from delphi7 and dialog with schneider pcs automat

Posted on 2007-11-22
12
418 Views
Last Modified: 2013-11-09
In the past I have write a program with delphi1 to send data to schneider automat I dialog with modicn pci-85 interface card thru interrupt $5C. Now I want rewrite this program with delphi7, I try to use netbios, but I access always network interface cad of the pc. How can I acces the modicon pci-85 inteface.
thank you.
0
Comment
Question by:knollcompusoft
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
12 Comments
 
LVL 18

Expert Comment

by:Johnjces
ID: 20351508
Do you have a code snipet we could see?

What OS did you use for the Delphi 1 application?
What OS are you using now for the Delphi 7 application?

Those are very important questions.

John
0
 

Author Comment

by:knollcompusoft
ID: 20356755
thank you for your answer.
For Delphi 1 I did use Win 98SE
for Delphi 7 I use win XP

code for ncb addname in delphi 1 with unit netbios who use int $5c
 with ncb do
  begin
   callname[1]:='D';
   callname[2]:='M';
   callname[3]:=chr(adresse); {43}
    Command   := $b0 {add_name};
    LanaNum   := 0; {adaptateur}
    retcode   := NBEInvalidLanA;
    NetBiosRequest(N);            
 end;

code for ncb open in delphi 7 with unit nb30 who use netap32.dll
 NCB.ncb_callname[0]:='D';
 NCB.ncb_callname[1]:='M';
 NCB.ncb_callname[2]:=chr(adresse); {43}
 NCB.ncb_command := Chr(NCBADDNAME); { $48 en sychrone $b0 en a.. }
 NCB.ncb_lana_num := chr(0);
 NCB.ncb_retcode := chr(NRC_INVADDRESS);
 NetBios(@NCB);

thank you
Jean Knoll
0
 
LVL 18

Expert Comment

by:Johnjces
ID: 20357925
Jean,

I do not now know what kind of access software/library (NCB) you are using or how it access the hardware.

In WinNT, 2K, XP and Vista you MUST have a device driver to directly address and access hardware or physical hardware addresses.

If the NCB library does not have such a function, or it is something you wrote, it could be handled. In other words, the BASIC peek and poke into a hardware location will not work without such device drivers.

There are many around and some good and free. But I do not know if that is what you need.

John
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

Author Comment

by:knollcompusoft
ID: 20358672
Thank you for your answer, I try to be clear.
In the past my first version who use the int $5c works fine.
Know my customer change is system on win xp. I rewrite all my application.
I study what kind of example I have in c.
I attach a small example in c who works on my system, in fact I want to do the same thing in delphi7.
Unfortunatly my customer canot find the sdk.
regards.
Jean Knoll
/*name test4.c*/
 
 
/* Copyright (C) Modicon, Inc. 1989,  All Rights Reserved. */
/*
This test program uses the SA85.SYS device driver to read 125 holding
registers from the MODBUS slave which is found at the given node number.
 
In order to use this program, enter the following command:
 
    A>TEST4 12
 
where "12" is the slave node we want to read from.
*/
 
 
/*
include
 
 
*/
#define STRICT
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <signal.h>
#include "netbios.h"
#include "netlib.h"
 
 
/*
prototypes
 
*/
int main(int argc, char *argv[] );
void dump(int qty, UNALIGNED USHORT* buff);
void control_c(int sig);
 
/*
global variables
 
 
*/
char mbuffer[256];
char path[ 80 ];
int completed;
 
/*
main()
 
 
*/
 
int main( argc, argv )
int argc;
char *argv[];
{
    NCB *nd;
    int ret_val;
    int i;
 
    printf( "MODBUS Command/Response test.  Strike any key to abort.\n" );
 
    if( argc < 2 ) {
        printf( "Usage is: A>TEST4 <slave node>\n");
        exit( 1 );
    }
    ret_val = sscanf( argv[ 1 ], "%d", &i );
    if( ret_val != 1 || i < 1 || i > 64 ) {
        printf( "Node number must be in the range 1 to 64. " );
        exit( 1 );
    }
 
    if( signal( SIGINT, control_c ) == SIG_ERR ) {
        printf( "Unable to redirect Control-C." );
        exit( 1 );
    }
    
    sprintf( path, "DM.%d.0.0.0.0", i );
 
    if ((nd = ncb_open( path, 0 )) == NULL) {
        printf("Unable to open DATA MASTER path.\n");
        exit(1);
        }
    printf("Path %02X opened\n", nd->NCB_NUM);
    printf("Routing info: %c%c.%d.%d.%d.%d.%d\n",
        nd->NCB_CALLNAME[0],
        nd->NCB_CALLNAME[1],
        nd->NCB_CALLNAME[2],
        nd->NCB_CALLNAME[3],
        nd->NCB_CALLNAME[4],
        nd->NCB_CALLNAME[5],
        nd->NCB_CALLNAME[6]);
 
    completed = 0;          /* global variable, do while zero */
    while( !completed ) {
	    if( kbhit() )
            completed = 1;
        /*
         * Note: filling in mbuffer[0] with the slave address
         * is actually unecessary, since it was specified above
         * in the ncb_open.  It is done here, and the buffer
         * pointer adjusted by 1 in ncb_send, to provide ease-of-use
         * and compatibility with existing modbus applications.
         */
        mbuffer[0] = 0x5;   /*slave address*/
        mbuffer[1] = 0x3;   /*command*/
        mbuffer[2] = 0x0;   /*offset high*/
        mbuffer[3] = 0x0;   /*offset low*/
        mbuffer[4] = 0x0;   /*reg count high*/
        mbuffer[5] = 125;   /* reg count low*/
        if (ncb_send(nd, 6, mbuffer, 10) != 0) {
                        /*send the command*/
            printf("Send error: %d.\n", nd->NCB_RETCODE);
            ret_val = ncb_close(nd);    /*close the path*/
            exit(1);
            }
        if (ncb_receive_wait(nd, mbuffer, 10) != 0)
                        /*try to receive*/
            printf("\nReceive error: %d.\n", nd->NCB_RETCODE);
        else 
		    dump( 125, (PUSHORT) &mbuffer[ 3 ]); 
    }
    ncb_close(nd);      /*close the path*/
    exit(0);            /* good exit */
    return( 0 );
}
 
/*
dump
 
 
Dump the contents of the buffer for the length specified.
 
*/
void dump(qty, buff)
int qty;				    /* qty of bytes to dump */
UNALIGNED USHORT* buff;	    /* buffer with the data */
	{					    /* dump_lines */
	int i = 0, j;
    unsigned int out_value;
 
	printf("\n");
	do	{
		printf("\n");
		for(j = 0;  j < 8 && i < qty;  j++,  i++) {
            out_value = ((*buff << 8) & 0xff00) | ((*buff >> 8) & 0xff);
            printf("%04X ", out_value);
            buff++;
        }
    } while (i < qty);
	printf("\n");
	}					/* dump_lines */
 
 
/*
control_c
 
 
This routine replaces the control-C handler supplied by DOS.  When you
type a control_C, the program will vector to this routine, which will
set the completed flag to non-zero.  In this test program, this will cause
the infinite loop within main to terminate.
*/
void control_c(int sig)
{
    signal( SIGINT, SIG_IGN );          /* disable control-c */
    completed = 1;                      /* will cause main loop to complete */
    signal( SIGINT, control_c );        /* reset control-c handler */
}

Open in new window

0
 
LVL 18

Accepted Solution

by:
Johnjces earned 500 total points
ID: 20358749
It appears to me that this I/O library was written for DOS and early versions of Windows, I.E. 3.X, 95, 98.

This simply will not work on NT, 2K, XP and Vista.

Without an updated IO device driver form this manufacturer you will have a tough time.

If you know what address locations you need to read and write have  a look at WinRingO:

http://openlibsys.org/
http://sourceforge.net/projects/winring0/

John
0
 

Author Comment

by:knollcompusoft
ID: 20358803
ok,
thank you,
I try to obtain one good release of sdk and I see wich library I can use in 32bits.
I don't know WinRingO.
I go to see if I can use.
Can I recontact you when I have the sdk?
Regards
Jean
0
 
LVL 18

Expert Comment

by:Johnjces
ID: 20358822
Certainly.

Best is through this unless you close it.

John
0
 

Author Comment

by:knollcompusoft
ID: 20382659
hello,
Now I have received the cyberlogic SDK for modicon interface (for C). You can see this sdk including library and examples here:
ftp://ftp.seyssel.org/secretsseyssels/cyberlogic
I wish to use the netlib in this library with delphi 7, in delphi7 I have one library : nb30 who use netlib32.dll who access network card.
Is it possible to modify nb30 for using the cyberlogic library.
thank you.
Regards.

0
 
LVL 18

Expert Comment

by:Johnjces
ID: 20382783
From here I do not know and cannot help you as I simply do not know. Sorry.

Also, sounds like a new question/thread.

John
0
 

Author Comment

by:knollcompusoft
ID: 20402125
Thank you very much for your remarks.
In the sdk of the modicon pci 85 card I have one dll: netlib.dll.
This dll acced to the card.
I write one delphi unit who access the dll and all works.
I send you sample of the code.
best regards
Jean Knoll
function ncb_open(name:pchar;lan:integer):pncb; stdcall;
implementation
function ncb_open; external 'netlib.dll' name 'ncb_open';

Open in new window

0
 
LVL 1

Expert Comment

by:Computer101
ID: 21216654
Forced accept.

Computer101
EE Admin
0

Featured Post

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When posting a question about a Cisco ASA, Cisco Router or Cisco Switch, it can aid diagnosis if a suitably sanitised copy of the config is provided. It is much better to leave as much of the configuration as original as possible, as it could be tha…
Hi there, This article summarizes what you need if you are going to set up your home or small business Network Attached Storage (NAS) to be accessible from the internet. Of course there are configuration differences based on your NAS or router ma…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question