Hallo, ich kommuniziere mit Chrome über die api an eine serielle
Schnittstelle, ansprechen will ich eine Relaiskarte
verbinden und disconnecten funktioniert, doch was muss ich senden.
4 bytes
1100 für init
3113 für relais 1 einschalten
Frage 1:) unten ist der Dataframe einmal in original, ist er richtig
übersetzt?
Frage 2:) Warum funktioniert das senden nicht?
Hat jemand Erfahrung?
is this the same command frame? use chrome.serial api relais card
Code:
1 | chrome.serial.connect("COM4", {bitrate: 19200}, onConnect);
|
2 | connectionId = connectionInfo.connectionId;
|
3 | output.textContent += " Databits: " + connectionInfo.dataBits;
|
4 | output.textContent += " parityBit: " + connectionInfo.parityBit;
|
5 | output.textContent += " stopBits: " + connectionInfo.stopBits;
|
6 | output.textContent += " ctsFlowControl: " + connectionInfo.ctsFlowControl;
|
7 | every thing perfect
|
// diconnect
Code:
1 | chrome.serial.disconnect(connectionId, onDisconnect);
|
DATAFRAME
1 | var buffer = new ArrayBuffer(3);
|
2 | var uint8view = new Uint8Array(buffer);
|
3 |
|
4 | uint8view[0] = 1; /* commando for init is 1*/
|
5 | uint8view[1] = 1; /* adress of card is 1*/
|
6 | uint8view[2] = 0; /* data for init */
|
7 | uint8view[3] = 0; /* checksum */
|
8 |
|
9 | // INIT END
|
10 |
|
11 | var buffer2 = new ArrayBuffer(3);
|
12 | var uint8view2 = new Uint8Array(buffer2);
|
13 |
|
14 | uint8view2[0] = 3; /* commando for enable relais */
|
15 | uint8view2[1] = 1; /* adress = 1*/
|
16 | uint8view2[2] = 1; /* data */
|
17 | uint8view2[3] = 3; /* checksum */
|
18 |
|
19 | chrome.serial.write(connectionId, buffer2, function() {});
|
after that nothing is successfull and the next lines are not working.
original code
1 | Code:
|
2 | Dim Send_buffer(0 To 3) As Byte
|
3 |
|
4 | Send_buffer(0) = Command_Byte 'Create command-frame
|
5 | Send_buffer(1) = Address_Byte
|
6 | Send_buffer(2) = Data_byte
|
7 | Send_buffer(3) = Command_Byte Xor Address_Byte Xor Data_byte 'Calculate "checksum"
|
8 |
|
9 | TextBox.Text = ("CMD: " & Command_Byte.ToString & ", Adr: " & Address_Byte.ToString & ", Data_byte: " & Data_byte.ToString & ", CRC: " & Send_buffer(3).ToString)
|