MajenkoLibraries / ICSC

Inter-Chip Serial Communications
BSD 3-Clause "New" or "Revised" License
81 stars 27 forks source link

How master can recieve msg from slave ? #10

Open yuranikspb opened 6 years ago

yuranikspb commented 6 years ago

I have problem i am create test project in proteus 1213123 Master: ` #include const int buttonPin = 3; const int ledPin = 4; const int portreadyled = 5; const int dePin = 2; int buttonState = 0; ICSC icsc(Serial,'A',dePin);

void setup() { // put your setup code here, to run once: // initialize the button pin as a input: pinMode(buttonPin, INPUT); // initialize the LED as an output: pinMode(ledPin, OUTPUT); pinMode(2,OUTPUT); Serial.begin(9600); icsc.begin(); icsc.registerCommand('G',&check); delay(2000); digitalWrite(ledPin, HIGH); delay(100); icsc.send('B', 'S');

}

void loop() {
icsc.process();
} void check(unsigned char src, char command, unsigned char len, char *data) { digitalWrite(ledPin, LOW);

} `

Slave : ` #include

include

const int buttonPin = 3; const int ledPin = 4; const int dePin = 2; int buttonState = 0;

ICSC icsc(Serial,'B',dePin); void setup() { // put your setup code here, to run once: // initialize the button pin as a input: pinMode(buttonPin, INPUT); // initialize the LED as an output: pinMode(ledPin, OUTPUT); pinMode(2,OUTPUT); Serial.begin(9600); icsc.begin(); icsc.registerCommand('S',&stat); } void loop() {

icsc.process();

//icsc.send('A', 'G'); } void stat(unsigned char src, char command, unsigned char len, char *data) {

delay(1000); for (int i=0; i <= 15; i++){ icsc.send('A', 'G'); icsc.process(); delay(50); }

} ` Algorithm: master send to slave command and led is high slave recieve command wait and 15times try send to master command for led is LOW

master react only on 5 why ?