Module: OrigenLink::ServerCom

Included in:
VectorBased
Defined in:
lib/origen_link/server_com.rb

Instance Method Summary collapse

Instance Method Details

#send_batch(vector_batch) ⇒ Object

Send the stored batch of vectors to the server



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
# File 'lib/origen_link/server_com.rb', line 78

def send_batch(vector_batch)
  vector_batch_str = @user_name + "\n" + vector_batch.join("\n") + "\n\n"
  user_status = ''
  success = false

  until success
    t1 = 0
    t2 = 0
    t3 = 0
    t4 = 0
    t5 = 0
    response = []
    t1 = Time.now
    TCPSocket.open(@address, @port) do |link|
      t2 = Time.now
      link.write(vector_batch_str)
      t3 =  Time.now
      while line = link.gets
        response << line.chomp
      end
      t4 = Time.now
    end
    t5 = Time.now

    user_status = response.delete_at(0)
    if @initial_comm_sent && ((user_status =~ /user_change/) || (response[0] =~ /Busy:/))
      # there has been a collision
      Origen.log.error 'A collision (another user interrupted your link session) has occured'
      Origen.log.error "When using debug mode ensure that you don't exceed the 20 minute communication time out"
      exit
    end

    if response[0] =~ /Busy:/
      Origen.log.error response[0] + ' retry in 1 second'
      sleep(1)
    else
      success = true
      @initial_comm_sent = true
    end

  end

  @total_comm_time += (t5 - t1)
  @total_connect_time += (t2 - t1)
  @total_xmit_time += (t3 - t2)
  @total_recv_time += (t4 - t3)
  @max_receive_time = (t4 - t3) if @max_receive_time < (t4 - t3)
  @total_packets += 1
  @pattern_link_messages.concat(vector_batch)
  response
end

#send_cmd(cmdstr, argstr) ⇒ Object

send a single command to the server

send_cmd(cmdstr, argstr)

cmdstr is a valid command.  <category>_<command>
  Ex: 'pin_assign'
argstr is a valid comma separated, no white space argument string.
  Ex: 'tclk,26,tms,19,tdi,16,tdo,23'

returns: response from server

This method connects to the socket being served by the debugger, sends
the command and arguments separated by a semicolon (Ex: 'pin_cycle:110H'),
then waits for a response.  The response is returned to the caller.

In addition, this method also keeps track of time elapsed transfering data
and waiting for a response.


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
# File 'lib/origen_link/server_com.rb', line 19

def send_cmd(cmdstr, argstr)
  # objects have to be created outside of the block
  # to be accessible outside of the block
  t1 = 0
  t2 = 0
  t3 = 0
  t4 = 0
  t5 = 0
  response = ''
  user_status = ''
  success = false

  until success
    t1 = Time.now

    # open a connection to the server, send the command and wait for a response
    TCPSocket.open(@address, @port) do |link|
      t2 = Time.now
      link.write(@user_name + "\n" + cmdstr + ':' + argstr + "\n\n")
      t3 = Time.now
      user_status = link.gets
      response = link.gets
      t4 = Time.now
    end

    t5 = Time.now

    if @initial_comm_sent && ((user_status =~ /user_change/) || (response =~ /Busy:/))
      # there has been a collision
      Origen.log.error 'A collision (another user interrupted your link session) has occured'
      Origen.log.error "When using debug mode ensure that you don't exceed the 20 minute communication time out"
      exit
    end

    if response =~ /Busy:/
      Origen.log.error response + ' retry in 1 second'
      sleep(1)
    else
      success = true
      @initial_comm_sent = true
    end
  end

  @total_comm_time += (t5 - t1)
  if @max_packet_time < (t5 - t1)
    @max_packet_time = (t5 - t1)
    @longest_packet = cmdstr + ':' + argstr
  end
  @total_connect_time += (t2 - t1)
  @total_xmit_time += (t3 - t2)
  @total_recv_time += (t4 - t3)
  @max_receive_time = (t4 - t3) if @max_receive_time < (t4 - t3)
  @total_packets += 1
  Origen.log.error 'nil response from server (likely died) for command(' + cmdstr + ':' + argstr + ')' if response.nil?
  @pattern_link_messages << "#{cmdstr}:#{argstr}"
  response    # ensure the response is passed along
end

#setup_cmd_response_logger(command, response) ⇒ Object

Handle a server response (inform of Failures)

There are several setup commands that initialize the debugger device with
information about how to interact with the dut.  All of the setup commands
return pass or fail.  This method exists so that the code doesn't have to
be duplicated by every setup method.


136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/origen_link/server_com.rb', line 136

def setup_cmd_response_logger(command, response)
  if !response.nil?
    # if the server died (which hopefully it never will) response is nil
    case response.chr
    when 'P'
      Origen.log.debug command + ' setup was successful'
    when 'F'
      Origen.log.error command + ' setup FAILED with the following message:'
      Origen.log.error response.chomp
    else
      Origen.log.error 'Non standard response from ' + command + ' setup: ' + response
    end
  else
    # response was nil.  The server died
    Origen.log.error command + ' caused a nil response.  The server likely died.'
  end
end