Bonjour,

J'ai très peu de connaissance en C est je suis assez bloqué ^^
Je vous explique j'ai un client dans l'extraction de granulat, ils ont un pont bascule permettant de récupérer le poids des camions.
Un ancien collègue avait créé un code en C qu'il avait compilé en ".exe" permettant de récupérer cette pesée depuis notre application développé en PHP/MySQL et installé sur un poste sous Windows.
Mon client souhaite changer son matériel qui devient obsolète et par la même occasion refondre l'application PHP/MySQL et souhaite passer sur un Mac mini pour le matériel.

Ma question: Sera-t-il toujours possible d'exécuter le ".exe" sur la machine Mac sur lequel sera hébergé l'application PHP/Mysql.

Ci-joint le code source fichier "bascule.c"

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include "uart.h"
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.H>
#include <stddef.H>
#include <stdlib.H>
 
/***************************************/
/*                                     */
/* fonction configuration du composant */
/*                                     */
/***************************************/
void uart_16550( int *voie, unsigned int *vitesse,
					int *nb_stop_bit, int *parity,
					int *type_of_parity, int *nb_bit_data )
{
	/* initialiser la configuration */
	unsigned int choix;
 
	clrscr(); /* efface l'ecran */
 
	/*
	 *	VITESSE
	 */
		/* mettre DLAB a 1 pour regler la vitesse */
		outportb( *voie + LCR, 0x80 );
 
		outportb( *voie + DRL, 0x0C );
		outportb( *voie + DRH, 0x00 );
		*vitesse = 9600;
 
		/* mettre DLAB a 0 */
		outportb( *voie + LCR, 0x00 );
 
	/*
	 *	PARITE ET BIT DE STOP
	 */
		outportb( *voie + LCR, 0x03 );
		*nb_stop_bit = 1;
		*parity = 0;
		*type_of_parity = 0;
		*nb_bit_data = 8;
 
}
 
/**************************************/
/*                                    */
/* fonction d'emission d'un octet     */
/* texte : caractere a emettre        */
/* port  : contient l'@ du port com X */
/*                                    */
/**************************************/
void emission( unsigned char texte, int port )
{
	while( ( inportb( port + LSR ) & 0x20 ) != 0x20 )
	{
	} /* boucle infini */
	outportb( port + TDR, texte );
}
 
/***************************************/
/*                                     */
/* fonction de reception d'un octet    */
/* port   : contient l'@ du port com X */
/*                                     */
/***************************************/
unsigned char reception( int port )
{
	unsigned char recu = 'n';
	/* test si le registre de LSR a une donnee presente */
	while( ( inportb( port + LSR ) & 0x01 ) != 0x01 )
	{
	} /* boucle infini */
	recu = inportb( port + RDR );
	return( recu );
}
 
/**********************************************************/
/*                                                        */
/* fonction de reception de N octet                       */
/* buffer  : contient l'@ depart pour octets en reception */
/* Maxbuff : taille d'octet desire par l'utilisateur      */
/* port    : contient l'@ du port com X                   */
/*                                                        */
/**********************************************************/
void RChnX( unsigned char *buffer, int port, int taille )
{
	int i;
	for( i = 0 ; i < taille ; i++ ) /* test si le registre de stockage emission est vide */
	{
		/* test si le registre de LSR a une donnee presente */
		while( ( inportb( port + LSR ) & 0x01 ) != 0x01 )
		{
		} /* boucle infinie */
		*buffer = reception( port );
		buffer++;
	}
}
 
/***********************/
/*                     */
/* fonction principale */
/*                     */
/***********************/
int main( int argc, char **argv )
{
	unsigned char data_emi_1_octet = 'p';
	unsigned char data_recu_1_octet;
	unsigned char data_recu_N_octet[50];
	int i;
	int poids;
 
	uart_1655 port_serie1;
 
	port_serie1.voie = COM1;
 
	uart_16550( &port_serie1.voie, &port_serie1.baud, &port_serie1.n_bit_stop,
				&port_serie1.parity, &port_serie1.odd_or_even, &port_serie1.n_bit_data );
 
	for( i = 0 ; i < 50 ; i++ )
		data_recu_N_octet[i] = '\x0';
 
	/*
	*	LOCAL
	*/
		outportb( ( port_serie1.voie ) + MCR, 0x00 );
 
 
	/**********************************/
	/*                                */
	/* reception emission sur 1 octet */
	/*                                */
	/**********************************/
 
	/* emission */
 
	fflush( stdin );
	fflush( stdout );
	data_emi_1_octet = 0x50;
	emission( data_emi_1_octet, port_serie1.voie );
	RChnX( data_recu_N_octet, port_serie1.voie, 7 );
	printf( "\n%s|", data_recu_N_octet );
 
	data_emi_1_octet = 0x49;
	emission( data_emi_1_octet, port_serie1.voie );
	RChnX( data_recu_N_octet, port_serie1.voie, 40 );
	printf( "\n%s|", data_recu_N_octet );
	return poids;
}
Fichier "uart.h"

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* Prototypage des classes de la librairie RS232*/
 
#ifndef __UART
#define __UART
 
#define COM1 0x3F8
#define COM2 0x2F8
 
/* offset d'adressage des registres */
 
#define  LCR 0x03
#define  LSR 0x05
#define  DRL 0x00
#define  DRH 0x01
#define  RDR 0x00
#define  TDR 0x00
#define  MCR 0x04
#define  FCR 0x02
#define  IIR 0x02
#define  IER 0x01
 
#define TIMEOUT 2
#define XON 	0x11
#define XOFF	0x13
/*#define DEBUG 1 A utiliser si mise au point : compilation conditionnelle*/
 
typedef struct uart_1655
{
   int			voie;
   unsigned int baud;
   int			n_bit_stop;
   int			parity;
   int			odd_or_even;
   int			n_bit_data;
}uart_1655;
 
/* prototypes des fonctions */
 
   /* initialise le coupleur */
   void uart_16550( int *, unsigned int *, int *, int *, int *, int * );
 
   /* emission d'un octet */
   void emission( unsigned char, int );
 
   /* reception d'un octet */
   unsigned char reception( int );
 
   void affiche( unsigned char );
 
   /* envoi de N octets */
   void EChnX( unsigned char *, int, int );
 
   /* reception de N octets */
   void RChnX( unsigned char *, int, int );
 
#endif
A noté également qu'actuellement la machine de pesé et le PC sont reliés via un câble type COM et que sur le mac on passera via un adapteur COM/USB

Merci par avance pour vos lumières.

Nicolas