[C#] Zmiana adresu IP na kontrolerze LED

0

Witam.
Zacznę od szczegółów Posiadam kontroler C-Power 3200/2200 i tablicę LED monochromatyczną. Potrzebuje pomocy w oprogramowaniu tego kontrolera. Do tego wszystkiego tworzę oprogramowanie w języku C#.

Czego dokonałem:
Komunikuje się z kontrolerem bez przeszkód. Wysyłam tekst i obrazy do tablicy LED, potrafię dzielić tablice na mniejsze okna i restartować kontroler z poziomu oprogramowania.
Mój problem tkwi w zmianie parametrów połączenia na kontrolerze. To znaczy, że łącze się z kontrolerem przez przypisany wcześniej (z góry) adres IP 192.168.1.100 i port 5200. Chcę zmieniać parametry, sterownika, żeby móc konfigurować kontroler pod względem adresu na komputerze - a nie na odwrót.
Zamieszczam parametry z API .

// API for Network
CP5200API int 	CALLING_CONV CP5200_Net_Init(DWORD dwIP, int nIPPort, DWORD dwIDCode, int nTimeOut );
CP5200API int     CALLING_CONV CP5200_Net_SetBindParam( DWORD dwClientIP , int nClientPort ); 
CP5200API int	CALLING_CONV CP5200_Net_Connect(void);
CP5200API int	CALLING_CONV CP5200_Net_IsConnected(void);
CP5200API int	CALLING_CONV CP5200_Net_Disconnect(void);
CP5200API int	CALLING_CONV CP5200_Net_Write(const BYTE* pBuf, int nLength);
CP5200API int	CALLING_CONV CP5200_Net_Read(BYTE* pBuf, int nSize);

Poniżej kod przez który łącze sie na starym IP

  
uint AdresIP = GetIP(AdresIPB.Text);
uint Maska= GetIP(MaskaB.Text);
int PortIP= Convert.ToInt32(portIPB.Text);
if (AdresIP != 0 && Maska!= 0)
     CP5200.CP5200_Net_Init(AdresIP , PortIP, Maska, 600);
ret = CP5200.CP5200_Net_Connect();

A tu wymyśliłem ,ze poprzez zastosowanie CP5200_Net_SetBindParam będę mógł ustawić parametry sterownika...

  
uint IPzmiana = GetIP(IPzmien.Text);
int PORTzmiana = Convert.ToInt32(PORTzmien.Text);
uint MASKAZmiana = GetIP(MASKAzmien.Text);
ret = CP5200.CP5200_Net_SetBindParam(IPzmiana, PORTzmiana); 

Niestety powyższy kod nie działa. Nie chodzi tu o podpięcie akcji pod przycisk, czy cos w tym stylu, ponieważ jest to tylko fragment kodu. Dodam, ze pracuje z dll,em "CP5200.dll". Moja aplikacja to Aplikacja okienkowa w języku c#. Proszę o jakiekolwiek porady.
Z góry dziękuje, Jacek.

1
  1. pokaż deklaracje tych funkcji w C#
  2. masz jakąś dokumentację do tej biblioteki? czy to SetBindParam w ogóle działa w ten sposób?
0
  1. Deklaracja funkcji dzięki którym komunikuje się z dll'em.
 private const string m_strPath = "CP5200.dll";

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern string CP5200_RS232_GetFileName();

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_RS232_SplitScreen(int nCardID, int nScrWidth, int nScrHeight, int nWndCnt, int[] pWndRects);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_Net_SplitScreen(int nCardID, int nScrWidth, int nScrHeight, int nWndCnt, int[] pWndRects);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_RS232_InitEx(IntPtr fName, int nBaudrate, int dwTimeout);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_Net_Init(uint dwIP, int nIPPort, uint dwIDCode, int nTimeOut);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_RS232_Open();

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_RS232_SendText(int nCardID, int nWndNo, IntPtr pText, int crColor, int nFontSize, int nSpeed, int nEffect, int nStayTime, int nAlignment);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_Net_SendText(int nCardID, int nWndNo, IntPtr pText, int crColor, int nFontSize, int nSpeed, int nEffect, int nStayTime, int nAlignment);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_RS232_SendTagText(int nCardID, int nWndNo, IntPtr pText, int crColor, int nFontSize, int nSpeed, int nEffect, int nStayTime, int nAlignment);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_Net_SendTagText(int nCardID, int nWndNo, IntPtr pText, int crColor, int nFontSize, int nSpeed, int nEffect, int nStayTime, int nAlignment);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_RS232_SendPicture(int nCardID, int nWndNo, int nPosX, int nPosY, int nCx, int nCy, IntPtr pPictureFile, int nSpeed, int nEffect, int nStayTime, int nPictRef);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_Net_SendPicture(int nCardID, int nWndNo, int nPosX, int nPosY, int nCx, int nCy, IntPtr pPictureFile, int nSpeed, int nEffect, int nStayTime, int nPictRef);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_RS232_SendStatic(int nCardID, int nWndNo, IntPtr pText, int crColor, int nFontSize, int nAlignment, int x, int y, int cx, int cy);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_Net_SendStatic(int nCardID, int nWndNo, IntPtr pText, int crColor, int nFontSize, int nAlignment, int x, int y, int cx, int cy);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_RS232_SendClock(int nCardID, int nWinNo, int nStayTime, int nCalendar, int nFormat, int nContent, int nFont, int nRed, int nGreen, int nBlue, IntPtr pTxt);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_Net_SendClock(int nCardID, int nWinNo, int nStayTime, int nCalendar, int nFormat, int nContent, int nFont, int nRed, int nGreen, int nBlue, IntPtr pTxt);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_RS232_SetTime(byte nCardID, byte[] pInfo);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_Net_SetTime(byte nCardID, byte[] pInfo);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_RS232_PlaySelectedPrg(int nCardID, int[] pSelected, int nSelCnt, int nOption);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_Net_PlaySelectedPrg(int nCardID, int[] pSelected, int nSelCnt, int nOption);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_Net_RestartApp(byte nCardID);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_Net_SetBindParam(uint IP, int Port);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
        public static extern int CP5200_MakeWriteBrightnessData(int hObj, byte pBuffer, int nBufSize);

        [DllImport(m_strPath, CharSet = CharSet.Auto)]
         public static extern int CP5200_CommData_Create(int nCommType, byte byCardID, uint dwIDCode);

       [DllImport(m_strPath, CharSet = CharSet.Auto)] 
         public static extern int CP5200_Net_Connect();

       [DllImport(m_strPath, CharSet = CharSet.Auto)] 
        public static extern int  CP5200_Net_IsConnected();
  1. W załączniku plik API MANUAL.
0

Proszę o jakiekolwiek porady odnośnie mojego problemu. Będę bardzo wdzięczny.

1 użytkowników online, w tym zalogowanych: 0, gości: 1