Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

trkall / T-Diagnostics

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Switch branch/tag
  • T-Diagnostics
  • src
  • com
  • tDiagnostics
  • diagnostics
  • blocks
  • ACKBlock.java
Find file
BlameHistoryPermalink
  • Tref's avatar
    upload structured project · bd8c3f69
    Tref committed 4 years ago
    bd8c3f69
ACKBlock.java 1.02 KB
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
package com.tDiagnostics.diagnostics.blocks;

import com.fazecast.jSerialComm.SerialPort;
import com.tDiagnostics.communication.handler.ConnectionHandler;

public class ACKBlock {
    public static void sendAckBlock(SerialPort device, ConnectionHandler con){
        System.out.println("START_sendAckBlock");
        con.sendByte(device, 0x03, true);
        con.readByte(device, 0x03, true);
        if(con.WRONG_ANSWER)
            return ;
        con.sendByte(device, con.blockCounter+1, true);
        con.readByte(device, con.blockCounter+1, true);
        if(con.WRONG_ANSWER)
            return ;

        con.sendByte(device, 0x09, true);
        con.readByte(device,0x09, true);
        if(con.WRONG_ANSWER)
            return ;

        con.sendByte(device, 0x03, true);

    }

    public static void readACK(SerialPort port, ConnectionHandler con){
        System.out.println("START_readACK");
        int ack = con.readByte(port,0, false);
        con.sendByte(port, 0xFF-ack, true);
        con.readByte(port,0, false);
    }
}